Exemplo n.º 1
0
 /// <summary>
 /// The Get methods return policies taking into account inheritance. If a policy
 /// can't be found it may return null, but never an 'undefined' policy.
 /// </summary>
 /// <returns>
 /// The policy of the given type, or null if not found.
 /// </returns>
 public T Get <T> () where T : class, IEquatable <T>, new ()
 {
     if (policies != null)
     {
         object policy;
         if (policies.TryGetValue(typeof(T), null, out policy))
         {
             if (!PolicyService.IsUndefinedPolicy(policy))
             {
                 return((T)policy);
             }
             else if (InheritDefaultPolicies)
             {
                 return(PolicyService.GetDefaultPolicy <T> ());
             }
             else
             {
                 return(null);
             }
         }
     }
     if (!InheritDefaultPolicies)
     {
         return(null);
     }
     else if (IsRoot)
     {
         return(PolicyService.GetDefaultPolicy <T> ());
     }
     else
     {
         return(ParentPolicies.Get <T> ());
     }
 }
Exemplo n.º 2
0
 internal object Get(Type type)
 {
     if (policies != null)
     {
         object policy;
         if (policies.TryGetValue(type, null, out policy))
         {
             if (!PolicyService.IsUndefinedPolicy(policy))
             {
                 return(policy);
             }
             return(GetDefaultPolicy(type));
         }
     }
     if (IsRoot)
     {
         return(GetDefaultPolicy(type));
     }
     else
     {
         return(ParentPolicies.Get(type));
     }
 }