示例#1
0
        public static bool IsDefined(this ParameterInfo element, Type attributeType)
        {
            IEnumerable <CustomAttributeData> matches = element.GetMatchingCustomAttributes(attributeType, inherit: true);

            return(matches.Any());
        }
示例#2
0
        public static IEnumerable <T> GetCustomAttributes <T>(this ParameterInfo element, bool inherit) where T : Attribute
        {
            IEnumerable <CustomAttributeData> matches = element.GetMatchingCustomAttributes(typeof(T), inherit, skipTypeValidation: true);

            return(matches.Select(m => (T)(m.Instantiate())));
        }
示例#3
0
        public static IEnumerable <Attribute> GetCustomAttributes(this ParameterInfo element, Type attributeType, bool inherit)
        {
            IEnumerable <CustomAttributeData> matches = element.GetMatchingCustomAttributes(attributeType, inherit);

            return(matches.Instantiate(attributeType));
        }
示例#4
0
        public static IEnumerable <Attribute> GetCustomAttributes(this ParameterInfo element, bool inherit)
        {
            IEnumerable <CustomAttributeData> matches = element.GetMatchingCustomAttributes(null, inherit, skipTypeValidation: true);

            return(matches.Select(m => m.Instantiate()));
        }
示例#5
0
        public static T GetCustomAttribute <T>(this ParameterInfo element, bool inherit) where T : Attribute
        {
            IEnumerable <CustomAttributeData> matches = element.GetMatchingCustomAttributes(typeof(T), inherit, skipTypeValidation: true);

            return(matches.OneOrNull <T>());
        }
        public static Attribute GetCustomAttribute(this ParameterInfo element, Type attributeType, bool inherit)
        {
            IEnumerable <CustomAttributeData> matches = element.GetMatchingCustomAttributes(attributeType, inherit);

            return(matches.OneOrNull <Attribute>());
        }