Esempio n. 1
0
        public static ITransientDefaultPolicy CreatePolicyWithName(string policyName)
        {
            var policy = new PolicyInstance(policyName);

            PolicyStore.Instance.AddPolicy(policy);

            return(policy);
        }
Esempio n. 2
0
        private void TryAddPolicy(string policyKey, PolicyInstance policyInstance)
        {
            if (!_policies.ContainsKey(policyKey))
            {
                var added = _policies.TryAdd(policyKey, policyInstance);

                if (!added)
                {
                    throw new Exception("A policy already exists for policy key: " + policyKey);
                }
            }
        }
Esempio n. 3
0
 internal void AddPolicy(PolicyInstance policyInstance)
 {
     if (policyInstance.MultipleKeys)
     {
         foreach (var policyKey in policyInstance.PolicyKeys)
         {
             TryAddPolicy(policyKey, policyInstance);
         }
     }
     else
     {
         TryAddPolicy(policyInstance.PolicyKey, policyInstance);
     }
 }