InternalGetCustomAttributes() private static method

private static InternalGetCustomAttributes ( EventInfo element, Type type, bool inherit ) : Attribute[]
element EventInfo
type Type
inherit bool
return Attribute[]
Esempio n. 1
0
        public static Attribute[] GetCustomAttributes(MemberInfo element, Type type, bool inherit)
        {
            if (element == (MemberInfo)null)
            {
                throw new ArgumentNullException("element");
            }
            if (type == (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.Event:
                return(Attribute.InternalGetCustomAttributes((EventInfo)element, type, inherit));

            case MemberTypes.Property:
                return(Attribute.InternalGetCustomAttributes((PropertyInfo)element, type, inherit));

            default:
                return(element.GetCustomAttributes(type, inherit) as Attribute[]);
            }
        }
Esempio n. 2
0
        public static Attribute[] GetCustomAttributes(MemberInfo element, bool inherit)
        {
            if (element == (MemberInfo)null)
            {
                throw new ArgumentNullException("element");
            }
            switch (element.MemberType)
            {
            case MemberTypes.Event:
                return(Attribute.InternalGetCustomAttributes((EventInfo)element, typeof(Attribute), inherit));

            case MemberTypes.Property:
                return(Attribute.InternalGetCustomAttributes((PropertyInfo)element, typeof(Attribute), inherit));

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