Ejemplo n.º 1
0
        public AuthorizationRuleWho(AuthorizationRuleWhoType whoType, string who)
        {
            _name = who;
            _whoType = whoType;

            if (IsGeneric(_whoType))
            {
                if (who != null)
                {
                    throw new ArgumentException("who must be null when whoType is generic");
                }
            }
            else
            {
                if (who == null)
                {
                    throw new ArgumentException("who may not be null when whoType is not generic");
                }
            }
        }
Ejemplo n.º 2
0
 public AuthorizationRuleWho(AuthorizationRuleWhoType whoType)
     : this(whoType, null)
 {
 }
Ejemplo n.º 3
0
 private static bool IsGeneric(AuthorizationRuleWhoType whoType)
 {
     if (whoType == AuthorizationRuleWhoType.GenericAll ||
         whoType == AuthorizationRuleWhoType.GenericAnonymous ||
         whoType == AuthorizationRuleWhoType.GenericAuthenticated)
     {
         return true;
     }
     else if (whoType == AuthorizationRuleWhoType.Role ||
         whoType == AuthorizationRuleWhoType.User)
     {
         return false;
     }
     else
     {
         throw new ArgumentException("Unsupported whoType " + whoType.ToString());
     }
 }