Exemplo n.º 1
0
        public static object[] GetCustomAttributes(CustomReflectionContext context, CustomParameterInfo parameter, Type attributeFilterType, bool inherit)
        {
            ParameterInfo        provider   = parameter.UnderlyingParameter;
            IEnumerable <object> attributes = GetFilteredAttributes(context, provider, attributeFilterType);

            return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
        }
Exemplo n.º 2
0
        public static object[] GetCustomAttributes(CustomReflectionContext context, CustomEventInfo evnt, Type attributeFilterType, bool inherit)
        {
            EventInfo            provider   = evnt.UnderlyingEvent;
            IEnumerable <object> attributes = GetFilteredAttributes(context, provider, attributeFilterType);

            return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
        }
Exemplo n.º 3
0
        public static object[] GetCustomAttributes(CustomReflectionContext context, CustomMethodInfo method, Type attributeFilterType, bool inherit)
        {
            IEnumerable <object> attributes = GetFilteredAttributes(context, method.UnderlyingMethod, attributeFilterType);

            if (!inherit)
            {
                return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
            }

            CustomMethodInfo baseMember = method.GetBaseDefinition() as CustomMethodInfo;

            if (baseMember == null || baseMember.Equals(method))
            {
                return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
            }

            // GetAttributeUsage is expensive and should be put off as much as possible.
            bool isSealed = attributeFilterType.IsSealed;
            bool inherited;
            bool allowMultiple;

            GetAttributeUsage(attributeFilterType, out inherited, out allowMultiple);

            if (isSealed && !inherited)
            {
                return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
            }

            // declaredAttributes should have already been filtered by attributeFilterType
            List <object> results = new List <object>(attributes);

            do
            {
                if (isSealed && results.Count > 0 && !allowMultiple)
                {
                    break;
                }

                method = baseMember;

                IEnumerable <object> inheritedAttributes = GetFilteredAttributes(context, method.UnderlyingMethod, attributeFilterType);
                CombineCustomAttributes(results, inheritedAttributes, attributeFilterType, inherited, allowMultiple);

                baseMember = method.GetBaseDefinition() as CustomMethodInfo;
            } while (baseMember != null && !baseMember.Equals(method));

            return(CollectionServices.ConvertListToArray(results, attributeFilterType));
        }
Exemplo n.º 4
0
 public override object[] GetCustomAttributes(bool inherit)
 {
     return(CollectionServices.IEnumerableToArray(_attributes, typeof(Attribute)));
 }
Exemplo n.º 5
0
 public override object[] GetCustomAttributes(Type attributeType, bool inherit)
 {
     return(CollectionServices.IEnumerableToArray(AttributeUtils.FilterCustomAttributes(_attributes, attributeType), attributeType));
 }