public static int AttributeCount <T> (Type objectType) where T : Attribute { MemberInfo[] members = objectType.GetMembers(); var attributeReader = new Reflection.AttributeReader(); return(members.Count(t => attributeReader .GetAttributes <T>(objectType, t) .Length > 0)); }
private MemberInfo GenerateAttribute(Type type) { MemberInfo[] members = type.GetMembers(); // Get All necessary attributes and corresponding fields var attributeReader = new Reflection.AttributeReader(); foreach (var member in members) { var attributesV = attributeReader.GetAttributes <Attributes.IsValues>(type, member); if (attributesV.Length > 0) { return(member); } } throw new Exception("Failed to find Value field"); }