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)); }
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)); }
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)); }
public override object[] GetCustomAttributes(bool inherit) { return(CollectionServices.IEnumerableToArray(_attributes, typeof(Attribute))); }
public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return(CollectionServices.IEnumerableToArray(AttributeUtils.FilterCustomAttributes(_attributes, attributeType), attributeType)); }