Пример #1
0
        // Token: 0x060015AF RID: 5551 RVA: 0x0006739C File Offset: 0x0006559C
        private static T GetAttribute <T>(Type type) where T : Attribute
        {
            Type associatedMetadataType = Class_470.GetAssociatedMetadataType(type);
            T    attribute;

            if (associatedMetadataType != null)
            {
                attribute = Class_514.GetAttribute <T>(associatedMetadataType, true);
                if (attribute != null)
                {
                    return(attribute);
                }
            }
            attribute = Class_514.GetAttribute <T>(type, true);
            if (attribute != null)
            {
                return(attribute);
            }
            foreach (Type attributeProvider in type.GetInterfaces())
            {
                attribute = Class_514.GetAttribute <T>(attributeProvider, true);
                if (attribute != null)
                {
                    return(attribute);
                }
            }
            return(default(T));
        }
Пример #2
0
        // Token: 0x060015B0 RID: 5552 RVA: 0x00067430 File Offset: 0x00065630
        private static T GetAttribute <T>(MemberInfo memberInfo) where T : Attribute
        {
            Type associatedMetadataType = Class_470.GetAssociatedMetadataType(memberInfo.DeclaringType);
            T    attribute;

            if (associatedMetadataType != null)
            {
                MemberInfo memberInfoFromType = Class_514.GetMemberInfoFromType(associatedMetadataType, memberInfo);
                if (memberInfoFromType != null)
                {
                    attribute = Class_514.GetAttribute <T>(memberInfoFromType, true);
                    if (attribute != null)
                    {
                        return(attribute);
                    }
                }
            }
            attribute = Class_514.GetAttribute <T>(memberInfo, true);
            if (attribute != null)
            {
                return(attribute);
            }
            if (memberInfo.DeclaringType != null)
            {
                foreach (Type targetType in memberInfo.DeclaringType.GetInterfaces())
                {
                    MemberInfo memberInfoFromType2 = Class_514.GetMemberInfoFromType(targetType, memberInfo);
                    if (memberInfoFromType2 != null)
                    {
                        attribute = Class_514.GetAttribute <T>(memberInfoFromType2, true);
                        if (attribute != null)
                        {
                            return(attribute);
                        }
                    }
                }
            }
            return(default(T));
        }