private static T GetAttribute <T>(Type type) where T : Attribute { T attribute; Type associatedMetadataType = JsonTypeReflector.GetAssociatedMetadataType(type); if (associatedMetadataType != null) { attribute = ReflectionUtils.GetAttribute <T>(associatedMetadataType, true); if (attribute != null) { return(attribute); } } attribute = ReflectionUtils.GetAttribute <T>(type, true); if (attribute != null) { return(attribute); } Type[] interfaces = type.GetInterfaces(); for (int i = 0; i < (int)interfaces.Length; i++) { attribute = ReflectionUtils.GetAttribute <T>(interfaces[i], true); if (attribute != null) { return(attribute); } } return(default(T)); }
private static T GetAttribute <T>(Type type) where T : Attribute { Type associatedMetadataType = JsonTypeReflector.GetAssociatedMetadataType(type); T attribute; if (associatedMetadataType != null) { attribute = ReflectionUtils.GetAttribute <T>(associatedMetadataType, true); if (attribute != null) { return(attribute); } } attribute = ReflectionUtils.GetAttribute <T>(type, true); if (attribute != null) { return(attribute); } Type[] interfaces = type.GetInterfaces(); for (int i = 0; i < interfaces.Length; i++) { Type attributeProvider = interfaces[i]; attribute = ReflectionUtils.GetAttribute <T>(attributeProvider, true); if (attribute != null) { return(attribute); } } return((T)((object)null)); }
private static T GetAttribute <T>(Type type) where T : Attribute { Type associatedMetadataType = JsonTypeReflector.GetAssociatedMetadataType(type); T attribute; if (associatedMetadataType != null) { attribute = ReflectionUtils.GetAttribute <T>(associatedMetadataType, true); if (attribute != null) { return(attribute); } } attribute = ReflectionUtils.GetAttribute <T>(type, true); if (attribute != null) { return(attribute); } foreach (Type attributeProvider in type.GetInterfaces()) { attribute = ReflectionUtils.GetAttribute <T>(attributeProvider, true); if (attribute != null) { return(attribute); } } return((T)((object)null)); }
private static T GetAttribute <T>(Type type) where T : Attribute { Type associatedMetadataType = JsonTypeReflector.GetAssociatedMetadataType(type); if (associatedMetadataType != null) { T attribute = ReflectionUtils.GetAttribute <T>((object)associatedMetadataType, true); if ((object)attribute != null) { return(attribute); } } T attribute1 = ReflectionUtils.GetAttribute <T>((object)type, true); if ((object)attribute1 != null) { return(attribute1); } foreach (object attributeProvider in type.GetInterfaces()) { T attribute2 = ReflectionUtils.GetAttribute <T>(attributeProvider, true); if ((object)attribute2 != null) { return(attribute2); } } return(default(T)); }
private static T GetAttribute <T>(MemberInfo memberInfo) where T : Attribute { T attribute; Type associatedMetadataType = JsonTypeReflector.GetAssociatedMetadataType(memberInfo.DeclaringType); if (associatedMetadataType != null) { MemberInfo memberInfoFromType = ReflectionUtils.GetMemberInfoFromType(associatedMetadataType, memberInfo); if (memberInfoFromType != null) { attribute = ReflectionUtils.GetAttribute <T>(memberInfoFromType, true); if (attribute != null) { return(attribute); } } } attribute = ReflectionUtils.GetAttribute <T>(memberInfo, true); if (attribute != null) { return(attribute); } if (memberInfo.DeclaringType != null) { Type[] interfaces = memberInfo.DeclaringType.GetInterfaces(); for (int i = 0; i < (int)interfaces.Length; i++) { MemberInfo memberInfoFromType1 = ReflectionUtils.GetMemberInfoFromType(interfaces[i], memberInfo); if (memberInfoFromType1 != null) { attribute = ReflectionUtils.GetAttribute <T>(memberInfoFromType1, true); if (attribute != null) { return(attribute); } } } } return(default(T)); }
private static T GetAttribute <T>(MemberInfo memberInfo) where T : Attribute { Type associatedMetadataType = JsonTypeReflector.GetAssociatedMetadataType(memberInfo.DeclaringType); if (associatedMetadataType != null) { MemberInfo memberInfoFromType = ReflectionUtils.GetMemberInfoFromType(associatedMetadataType, memberInfo); if (memberInfoFromType != null) { T attribute = ReflectionUtils.GetAttribute <T>((object)memberInfoFromType, true); if ((object)attribute != null) { return(attribute); } } } T attribute1 = ReflectionUtils.GetAttribute <T>((object)memberInfo, true); if ((object)attribute1 != null) { return(attribute1); } if (memberInfo.DeclaringType != null) { foreach (Type targetType in memberInfo.DeclaringType.GetInterfaces()) { MemberInfo memberInfoFromType = ReflectionUtils.GetMemberInfoFromType(targetType, memberInfo); if (memberInfoFromType != null) { T attribute2 = ReflectionUtils.GetAttribute <T>((object)memberInfoFromType, true); if ((object)attribute2 != null) { return(attribute2); } } } } return(default(T)); }
private static T GetAttribute <T>(MemberInfo memberInfo) where T : Attribute { Type associatedMetadataType = JsonTypeReflector.GetAssociatedMetadataType(memberInfo.get_DeclaringType()); T attribute; if (associatedMetadataType != null) { MemberInfo memberInfoFromType = ReflectionUtils.GetMemberInfoFromType(associatedMetadataType, memberInfo); if (memberInfoFromType != null) { attribute = ReflectionUtils.GetAttribute <T>(memberInfoFromType, true); if (attribute != null) { return(attribute); } } } attribute = ReflectionUtils.GetAttribute <T>(memberInfo, true); if (attribute != null) { return(attribute); } Type[] interfaces = memberInfo.get_DeclaringType().GetInterfaces(); for (int i = 0; i < interfaces.Length; i++) { Type targetType = interfaces[i]; MemberInfo memberInfoFromType2 = ReflectionUtils.GetMemberInfoFromType(targetType, memberInfo); if (memberInfoFromType2 != null) { attribute = ReflectionUtils.GetAttribute <T>(memberInfoFromType2, true); if (attribute != null) { return(attribute); } } } return((T)((object)null)); }