InternalParamIsDefined() private static method

private static InternalParamIsDefined ( MethodInfo method, ParameterInfo param, Type type, bool inherit ) : bool
method MethodInfo
param ParameterInfo
type Type
inherit bool
return bool
Esempio n. 1
0
        public static bool IsDefined(ParameterInfo element, Type attributeType, bool inherit)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (attributeType == (Type)null)
            {
                throw new ArgumentNullException("attributeType");
            }
            if (!attributeType.IsSubclassOf(typeof(Attribute)) && attributeType != typeof(Attribute))
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_MustHaveAttributeBaseClass"));
            }
            switch (element.Member.MemberType)
            {
            case MemberTypes.Constructor:
                return(element.IsDefined(attributeType, false));

            case MemberTypes.Method:
                return(Attribute.InternalParamIsDefined(element, attributeType, inherit));

            case MemberTypes.Property:
                return(element.IsDefined(attributeType, false));

            default:
                throw new ArgumentException(Environment.GetResourceString("Argument_InvalidParamInfo"));
            }
        }