public static SubDocumentAllowedType GetSubDocumentAllowedType(this Enum enumValue, SubDocumentAllowedType defaultValue = SubDocumentAllowedType.All) { var member = enumValue.GetType().GetMember(enumValue.ToString())[0]; var attribute = member.GetCustomAttributes(typeof(AllowedForDocumentAttribute), false); if (!attribute.Any()) { return defaultValue; } return ((AllowedForDocumentAttribute)attribute[0]).SubDocumentAllowed; }
public static SubDocumentAllowedType GetSubDocumentAllowedType(this Enum enumValue, SubDocumentAllowedType defaultValue = SubDocumentAllowedType.All) { var member = enumValue.GetType().GetMember(enumValue.ToString())[0]; var attribute = member.GetCustomAttributes(typeof(AllowedForDocumentAttribute), false); if (!attribute.Any()) { return(defaultValue); } return(((AllowedForDocumentAttribute)attribute[0]).SubDocumentAllowed); }
public AllowedForDocumentAttribute(SubDocumentAllowedType subDocumentAllowed) { SubDocumentAllowed = subDocumentAllowed; }