System.Attribute.GetCustomAttributes C# (CSharp) Method

GetCustomAttributes() public static method

public static GetCustomAttributes ( MemberInfo element, Type type, bool inherit ) : Attribute[]
element MemberInfo
type Type
inherit bool
return Attribute[]
        public static Attribute[] GetCustomAttributes(MemberInfo element, Type type, bool inherit)
        {
            if (element == null)
                throw new ArgumentNullException("element");

            if (type == null)
                throw new ArgumentNullException("type");
            
            if (!type.IsSubclassOf(typeof(Attribute)) && type != typeof(Attribute))
                throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));

            switch (element.MemberType)
            {
                case MemberTypes.Property:  
                    return InternalGetCustomAttributes((PropertyInfo)element, type, inherit);

                case MemberTypes.Event: 
                    return InternalGetCustomAttributes((EventInfo)element, type, inherit);

                default:
                    return element.GetCustomAttributes(type, inherit) as Attribute[];
            }
        }

Same methods

Attribute::GetCustomAttributes ( Assembly element ) : System.Attribute[]
Attribute::GetCustomAttributes ( Assembly element, Type attributeType ) : System.Attribute[]
Attribute::GetCustomAttributes ( Assembly element, Type attributeType, bool inherit ) : System.Attribute[]
Attribute::GetCustomAttributes ( Assembly element, bool inherit ) : System.Attribute[]
Attribute::GetCustomAttributes ( MemberInfo element ) : Attribute[]
Attribute::GetCustomAttributes ( MemberInfo element, Type type ) : Attribute[]
Attribute::GetCustomAttributes ( MemberInfo element, bool inherit ) : Attribute[]
Attribute::GetCustomAttributes ( Module element ) : Attribute[]
Attribute::GetCustomAttributes ( Module element, Type attributeType ) : Attribute[]
Attribute::GetCustomAttributes ( Module element, Type attributeType, bool inherit ) : Attribute[]
Attribute::GetCustomAttributes ( Module element, bool inherit ) : Attribute[]
Attribute::GetCustomAttributes ( ParameterInfo element ) : Attribute[]
Attribute::GetCustomAttributes ( ParameterInfo element, Type attributeType ) : Attribute[]
Attribute::GetCustomAttributes ( ParameterInfo element, Type attributeType, bool inherit ) : Attribute[]
Attribute::GetCustomAttributes ( ParameterInfo element, bool inherit ) : Attribute[]

Usage Example

Beispiel #1
0
 public static Attribute[] GetCustomAttributes(Assembly element)
 {
     return(Attribute.GetCustomAttributes(element, true));
 }
All Usage Examples Of System.Attribute::GetCustomAttributes