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"); } } }
public AuthorizationRuleWho(AuthorizationRuleWhoType whoType) : this(whoType, null) { }
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()); } }