From a54a67bb5919c238a48a2ac719cd530a0c34de7e Mon Sep 17 00:00:00 2001 From: Ryan Gribble Date: Mon, 14 Dec 2015 21:18:26 +1000 Subject: [PATCH] Make Contexts IReadonlyList implemented as per CommitActivity Tidy up to be consistent with other model classes --- Octokit/Models/Response/BranchProtection.cs | 32 ++++++++++++--------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/Octokit/Models/Response/BranchProtection.cs b/Octokit/Models/Response/BranchProtection.cs index f3e7518345..31a2f3f1da 100644 --- a/Octokit/Models/Response/BranchProtection.cs +++ b/Octokit/Models/Response/BranchProtection.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; +using System.Linq; namespace Octokit { @@ -12,6 +14,14 @@ namespace Octokit [DebuggerDisplay("{DebuggerDisplay,nq}")] public class BranchProtection { + public BranchProtection() { } + + public BranchProtection(bool enabled, RequiredStatusChecks requiredStatusChecks) + { + Enabled = enabled; + RequiredStatusChecks = requiredStatusChecks; + } + /// /// Should this branch be protected or not /// @@ -22,12 +32,6 @@ public class BranchProtection /// public RequiredStatusChecks RequiredStatusChecks { get; private set; } - public BranchProtection(bool enabled, RequiredStatusChecks requiredStatusChecks) - { - Enabled = enabled; - RequiredStatusChecks = requiredStatusChecks; - } - internal string DebuggerDisplay { get @@ -40,6 +44,14 @@ internal string DebuggerDisplay [DebuggerDisplay("{DebuggerDisplay,nq}")] public class RequiredStatusChecks { + public RequiredStatusChecks() { } + + public RequiredStatusChecks(EnforcementLevel enforcementLevel, IEnumerable contexts) + { + EnforcementLevel = enforcementLevel; + Contexts = new ReadOnlyCollection(contexts.ToList()); + } + /// /// Who required status checks apply to /// @@ -48,13 +60,7 @@ public class RequiredStatusChecks /// /// The list of status checks to require in order to merge into this /// - public ICollection Contexts { get; private set; } - - public RequiredStatusChecks(EnforcementLevel enforcementLevel, ICollection contexts) - { - EnforcementLevel = enforcementLevel; - Contexts = contexts; - } + public IReadOnlyList Contexts { get; private set; } internal string DebuggerDisplay {