public class Attribute { protected Attribute (); public static Attribute GetCustomAttribute (MemberInfo element, Type attributeType); public static Attribute GetCustomAttribute (ParameterInfo element, Type attributeType); public static Attribute GetCustomAttribute (Module element, Type attributeType); public static Attribute GetCustomAttribute (Assembly element, Type attributeType); public static Attribute[] GetCustomAttributes (MemberInfo element, Type attributeType); public static Attribute[] GetCustomAttributes (ParameterInfo element, Type attributeType); public static Attribute[] GetCustomAttributes (Module element, Type attributeType); public static Attribute[] GetCustomAttributes (Assembly element, Type attributeType); public static Attribute[] GetCustomAttributes(MemberInfo element); public static Attribute[] GetCustomAttributes(ParameterInfo element); public static Attribute[] GetCustomAttributes(Module element); public static Attribute[] GetCustomAttributes(Assembly element); public static bool IsDefined (MemberInfo element, Type attributeType); public static bool IsDefined (ParameterInfo element, Type attributeType); public static bool IsDefined (Module element, Type attributeType); public static bool IsDefined (Assembly element, Type attributeType); }
All Attributes inherit (directly or indirectly) from System.Attribute. This common base class gives all Attributes a central point in the hierarchy from which they can inherit. Compilers and other development tools use this information to identify which types are Custom Attributes
Just inheriting from System.Attribute gives an attribute certain default behaviors: Allowed on any element, Inheritable, duplicate instances are not allowed.
Returns an instance of customAttributeType or null if non-exists on the given attributedElement. If customAttributeType is a base class or interface this method will return any implementation of subclass of that type. Throws an AmbiguousMatchException if there is more than one attribute of type customAttributeType defined on this member. Ignores any attributes that don’t inherit from System.Attribute.
Returns an instance of each custom attribute defined on the given attributedElement or an empty array if non-exists. If customAttributeType is a base class or interface this method will return any implementation of subclass of that type. Returns an empty array if non-custom attributes exists on this the given element. Ignores any attributes that don’t inherit from System.Attribute. If a type is specified, the array returned must be an array of that type.
Returns true if this attribute is defined on the given element (including inherited members)