Пример #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>());
        }