private static AccessType GetInternal(Enum accessType) { Type type = accessType.GetType(); if (!Attribute.IsDefined(type, typeof(AccessTypeAttribute), false)) { throw new ArgumentException( string.Format( "Enumerated type '{0}' cannot be used as an access type. Valid access types must have the {1} applied.", type.FullName, typeof(AccessTypeAttribute).FullName), "accessType"); } return(new AccessType(EnumWrapper.Get(accessType))); }
private static Dictionary <string, EnumWrapper> InitializeStates(IDictionary <string, Enum> states) { Dictionary <string, EnumWrapper> securityStates = new Dictionary <string, EnumWrapper>(); foreach (KeyValuePair <string, Enum> valuePair in states) { Type stateType = valuePair.Value.GetType(); if (!s_validSecurityStateTypeCache.GetOrCreateValue(stateType, key => AttributeUtility.IsDefined <SecurityStateAttribute> (key, false))) { string message = string.Format( "Enumerated Type '{0}' cannot be used as a security state. Valid security states must have the {1} applied.", stateType, typeof(SecurityStateAttribute).FullName); throw new ArgumentException(message, "states"); } securityStates.Add(valuePair.Key, EnumWrapper.Get(valuePair.Value)); } return(securityStates); }
private static EnumWrapper[] InitializeAbstractRoles(ICollection <Enum> abstractRoles) { List <EnumWrapper> abstractRoleList = new List <EnumWrapper>(); foreach (Enum abstractRole in abstractRoles) { Type roleType = abstractRole.GetType(); if (!s_validAbstractRoleTypeCache.GetOrCreateValue(roleType, key => AttributeUtility.IsDefined <AbstractRoleAttribute> (key, false))) { string message = string.Format( "Enumerated Type '{0}' cannot be used as an abstract role. Valid abstract roles must have the {1} applied.", roleType, typeof(AbstractRoleAttribute).FullName); throw new ArgumentException(message, "abstractRoles"); } abstractRoleList.Add(EnumWrapper.Get(abstractRole)); } return(abstractRoleList.ToArray()); }