Skip to content

Commit

Permalink
Make Contexts IReadonlyList implemented as per CommitActivity
Browse files Browse the repository at this point in the history
Tidy up to be consistent with other model classes
  • Loading branch information
ryangribble committed Dec 14, 2015
1 parent 8f84d18 commit a54a67b
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions Octokit/Models/Response/BranchProtection.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -12,6 +14,14 @@ namespace Octokit
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class BranchProtection
{
public BranchProtection() { }

public BranchProtection(bool enabled, RequiredStatusChecks requiredStatusChecks)
{
Enabled = enabled;
RequiredStatusChecks = requiredStatusChecks;
}

/// <summary>
/// Should this branch be protected or not
/// </summary>
Expand All @@ -22,12 +32,6 @@ public class BranchProtection
/// </summary>
public RequiredStatusChecks RequiredStatusChecks { get; private set; }

public BranchProtection(bool enabled, RequiredStatusChecks requiredStatusChecks)
{
Enabled = enabled;
RequiredStatusChecks = requiredStatusChecks;
}

internal string DebuggerDisplay
{
get
Expand All @@ -40,6 +44,14 @@ internal string DebuggerDisplay
[DebuggerDisplay("{DebuggerDisplay,nq}")]
public class RequiredStatusChecks
{
public RequiredStatusChecks() { }

public RequiredStatusChecks(EnforcementLevel enforcementLevel, IEnumerable<string> contexts)
{
EnforcementLevel = enforcementLevel;
Contexts = new ReadOnlyCollection<string>(contexts.ToList());
}

/// <summary>
/// Who required status checks apply to
/// </summary>
Expand All @@ -48,13 +60,7 @@ public class RequiredStatusChecks
/// <summary>
/// The list of status checks to require in order to merge into this <see cref="Branch"/>
/// </summary>
public ICollection<string> Contexts { get; private set; }

public RequiredStatusChecks(EnforcementLevel enforcementLevel, ICollection<string> contexts)
{
EnforcementLevel = enforcementLevel;
Contexts = contexts;
}
public IReadOnlyList<string> Contexts { get; private set; }

internal string DebuggerDisplay
{
Expand Down

0 comments on commit a54a67b

Please sign in to comment.