public static IList <CustomAttributeData> __GetCustomAttributes(MemberInfo member, Type attributeType, bool inherit) { if (!member.IsBaked) { // like .NET we we don't return custom attributes for unbaked members throw new NotImplementedException(); } if (!inherit || !IsInheritableAttribute(attributeType)) { return(GetCustomAttributesImpl(null, member, attributeType) ?? EmptyList); } List <CustomAttributeData> list = new List <CustomAttributeData>(); for (; ;) { GetCustomAttributesImpl(list, member, attributeType); Type type = member as Type; if (type != null) { type = type.BaseType; if (type == null) { return(list); } member = type; continue; } MethodInfo method = member as MethodInfo; if (method != null) { MemberInfo prev = member; method = method.GetBaseDefinition(); if (method == null || method == prev) { return(list); } member = method; continue; } return(list); } }
public static IList <CustomAttributeData> __GetCustomAttributes(MemberInfo member, Type attributeType, bool inherit) { if (!inherit || !IsInheritableAttribute(attributeType)) { return(member.GetCustomAttributesData(attributeType)); } List <CustomAttributeData> list = new List <CustomAttributeData>(); for (; ;) { list.AddRange(member.GetCustomAttributesData(attributeType)); Type type = member as Type; if (type != null) { type = type.BaseType; if (type == null) { return(list); } member = type; continue; } MethodInfo method = member as MethodInfo; if (method != null) { MemberInfo prev = member; method = method.GetBaseDefinition(); if (method == null || method == prev) { return(list); } member = method; continue; } return(list); } }