コード例 #1
0
 public LinksPolicyBuilder <TResource> Combine(ILinksPolicy policy)
 {
     foreach (var requirement in policy.Requirements)
     {
         Requirements.Add(requirement);
     }
     return(this);
 }
コード例 #2
0
        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())));
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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));
        }
コード例 #5
0
 public void AddPolicy <TResource>(ILinksPolicy policy)
 {
     AddPolicy <TResource>("Default", policy);
 }