public LinksPolicyBuilder <TResource> Combine(ILinksPolicy policy) { foreach (var requirement in policy.Requirements) { Requirements.Add(requirement); } return(this); }
private static void AssertPoliciesMatch(ILinksPolicy policyToAdd, ILinksPolicy addedPolicy) { Assert.NotNull(addedPolicy); Assert.True(policyToAdd.Requirements.Count == addedPolicy.Requirements.Count); var expectedRequirements = policyToAdd.Requirements; Assert.True(policyToAdd.Requirements.All(r => expectedRequirements.Any(er => er.GetType() == r.GetType()))); }
public void AddPolicy <TResource>(string name, ILinksPolicy policy) { if (String.IsNullOrEmpty(name)) { throw new ArgumentException("Policy name cannot be null.", nameof(name)); } if (policy == null) { throw new ArgumentNullException(nameof(policy)); } var policyName = ConstructFullPolicyName <TResource>(name); PolicyMap[policyName] = policy; }
public static Task AddLinksAsync <T>(this ILinksService service, T linkContainer, ILinksPolicy /*<T>*/ policy) where T : ILinkContainer { if (service == null) { throw new ArgumentNullException(nameof(service)); } if (policy == null) { throw new ArgumentNullException(nameof(policy)); } return(service.AddLinksAsync(linkContainer, policy.Requirements)); }
public void AddPolicy <TResource>(ILinksPolicy policy) { AddPolicy <TResource>("Default", policy); }