// Token: 0x0600445F RID: 17503 RVA: 0x000FAEFC File Offset: 0x000F90FC
 private static bool AllowCriticalCustomAttributes(RuntimeType type)
 {
     if (type.IsGenericParameter)
     {
         MethodBase declaringMethod = type.DeclaringMethod;
         if (declaringMethod != null)
         {
             return(CustomAttribute.AllowCriticalCustomAttributes(declaringMethod));
         }
         type = (type.DeclaringType as RuntimeType);
     }
     return(!type.IsSecurityTransparent || CustomAttribute.SpecialAllowCriticalAttributes(type));
 }
Пример #2
0
        internal static object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType)
        {
            int count = 0;

            Attribute[] customAttributes1 = PseudoCustomAttribute.GetCustomAttributes(parameter, caType, out count);
            object[]    customAttributes2 = CustomAttribute.GetCustomAttributes(parameter.GetRuntimeModule(), parameter.MetadataToken, count, caType, !CustomAttribute.AllowCriticalCustomAttributes(parameter));
            if (count > 0)
            {
                Array.Copy((Array)customAttributes1, 0, (Array)customAttributes2, customAttributes2.Length - count, count);
            }
            return(customAttributes2);
        }
Пример #3
0
        internal static object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType)
        {
            int count = 0;

            Attribute[] customAttributes1 = PseudoCustomAttribute.GetCustomAttributes(ctor, caType, true, out count);
            object[]    customAttributes2 = CustomAttribute.GetCustomAttributes(ctor.GetRuntimeModule(), ctor.MetadataToken, count, caType, !CustomAttribute.AllowCriticalCustomAttributes((MethodBase)ctor));
            if (count > 0)
            {
                Array.Copy((Array)customAttributes1, 0, (Array)customAttributes2, customAttributes2.Length - count, count);
            }
            return(customAttributes2);
        }
Пример #4
0
        internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
        {
            if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
            {
                method = method.GetGenericMethodDefinition() as RuntimeMethodInfo;
            }
            int count = 0;

            Attribute[] customAttributes1 = PseudoCustomAttribute.GetCustomAttributes(method, caType, true, out count);
            if (!inherit || caType.IsSealed && !CustomAttribute.GetAttributeUsage(caType).Inherited)
            {
                object[] customAttributes2 = CustomAttribute.GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, count, caType, !CustomAttribute.AllowCriticalCustomAttributes((MethodBase)method));
                if (count > 0)
                {
                    Array.Copy((Array)customAttributes1, 0, (Array)customAttributes2, customAttributes2.Length - count, count);
                }
                return(customAttributes2);
            }
            List <object> objectList        = new List <object>();
            bool          mustBeInheritable = false;
            Type          elementType       = (caType == (RuntimeType)null || caType.IsValueType ? 1 : (caType.ContainsGenericParameters ? 1 : 0)) != 0 ? typeof(object) : (Type)caType;

            while (count > 0)
            {
                objectList.Add((object)customAttributes1[--count]);
            }
            for (; (MethodInfo)method != (MethodInfo)null; method = method.GetParentDefinition())
            {
                object[] customAttributes2 = CustomAttribute.GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, (IList)objectList, !CustomAttribute.AllowCriticalCustomAttributes((MethodBase)method));
                mustBeInheritable = true;
                for (int index = 0; index < customAttributes2.Length; ++index)
                {
                    objectList.Add(customAttributes2[index]);
                }
            }
            object[] attributeArrayHelper = CustomAttribute.CreateAttributeArrayHelper(elementType, objectList.Count);
            Array.Copy((Array)objectList.ToArray(), 0, (Array)attributeArrayHelper, 0, objectList.Count);
            return(attributeArrayHelper);
        }
Пример #5
0
 private static bool AllowCriticalCustomAttributes(RuntimeParameterInfo parameter)
 {
     return(CustomAttribute.AllowCriticalCustomAttributes(parameter.DefiningMethod));
 }
Пример #6
0
        internal static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
        {
            if (type.GetElementType() != (Type)null)
            {
                if (!caType.IsValueType)
                {
                    return(CustomAttribute.CreateAttributeArrayHelper((Type)caType, 0));
                }
                return(EmptyArray <object> .Value);
            }
            if (type.IsGenericType && !type.IsGenericTypeDefinition)
            {
                type = type.GetGenericTypeDefinition() as RuntimeType;
            }
            int count = 0;

            Attribute[] customAttributes1 = PseudoCustomAttribute.GetCustomAttributes(type, caType, true, out count);
            if (!inherit || caType.IsSealed && !CustomAttribute.GetAttributeUsage(caType).Inherited)
            {
                object[] customAttributes2 = CustomAttribute.GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, count, caType, !CustomAttribute.AllowCriticalCustomAttributes(type));
                if (count > 0)
                {
                    Array.Copy((Array)customAttributes1, 0, (Array)customAttributes2, customAttributes2.Length - count, count);
                }
                return(customAttributes2);
            }
            List <object> objectList        = new List <object>();
            bool          mustBeInheritable = false;
            Type          elementType       = (caType == (RuntimeType)null || caType.IsValueType ? 1 : (caType.ContainsGenericParameters ? 1 : 0)) != 0 ? typeof(object) : (Type)caType;

            while (count > 0)
            {
                objectList.Add((object)customAttributes1[--count]);
            }
            for (; type != (RuntimeType)typeof(object) && type != (RuntimeType)null; type = type.BaseType as RuntimeType)
            {
                object[] customAttributes2 = CustomAttribute.GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, 0, caType, mustBeInheritable, (IList)objectList, !CustomAttribute.AllowCriticalCustomAttributes(type));
                mustBeInheritable = true;
                for (int index = 0; index < customAttributes2.Length; ++index)
                {
                    objectList.Add(customAttributes2[index]);
                }
            }
            object[] attributeArrayHelper = CustomAttribute.CreateAttributeArrayHelper(elementType, objectList.Count);
            Array.Copy((Array)objectList.ToArray(), 0, (Array)attributeArrayHelper, 0, objectList.Count);
            return(attributeArrayHelper);
        }
        internal static object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType)
        {
            int num = 0;

            Attribute[] customAttributes  = PseudoCustomAttribute.GetCustomAttributes(parameter, caType, out num);
            object[]    customAttributes2 = CustomAttribute.GetCustomAttributes(parameter.GetRuntimeModule(), parameter.MetadataToken, num, caType, !CustomAttribute.AllowCriticalCustomAttributes(parameter));
            if (num > 0)
            {
                Array.Copy(customAttributes, 0, customAttributes2, customAttributes2.Length - num, num);
            }
            return(customAttributes2);
        }
        internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit)
        {
            if (method.IsGenericMethod && !method.IsGenericMethodDefinition)
            {
                method = (method.GetGenericMethodDefinition() as RuntimeMethodInfo);
            }
            int i = 0;

            Attribute[] customAttributes = PseudoCustomAttribute.GetCustomAttributes(method, caType, true, out i);
            if (!inherit || (caType.IsSealed && !CustomAttribute.GetAttributeUsage(caType).Inherited))
            {
                object[] customAttributes2 = CustomAttribute.GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, i, caType, !CustomAttribute.AllowCriticalCustomAttributes(method));
                if (i > 0)
                {
                    Array.Copy(customAttributes, 0, customAttributes2, customAttributes2.Length - i, i);
                }
                return(customAttributes2);
            }
            List <object> list = new List <object>();
            bool          mustBeInheritable = false;
            Type          elementType       = (caType == null || caType.IsValueType || caType.ContainsGenericParameters) ? typeof(object) : caType;

            while (i > 0)
            {
                list.Add(customAttributes[--i]);
            }
            while (method != null)
            {
                object[] customAttributes3 = CustomAttribute.GetCustomAttributes(method.GetRuntimeModule(), method.MetadataToken, 0, caType, mustBeInheritable, list, !CustomAttribute.AllowCriticalCustomAttributes(method));
                mustBeInheritable = true;
                for (int j = 0; j < customAttributes3.Length; j++)
                {
                    list.Add(customAttributes3[j]);
                }
                method = method.GetParentDefinition();
            }
            object[] array = CustomAttribute.CreateAttributeArrayHelper(elementType, list.Count);
            Array.Copy(list.ToArray(), 0, array, 0, list.Count);
            return(array);
        }
 internal static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit)
 {
     if (type.GetElementType() != null)
     {
         if (!caType.IsValueType)
         {
             return(CustomAttribute.CreateAttributeArrayHelper(caType, 0));
         }
         return(EmptyArray <object> .Value);
     }
     else
     {
         if (type.IsGenericType && !type.IsGenericTypeDefinition)
         {
             type = (type.GetGenericTypeDefinition() as RuntimeType);
         }
         int         i = 0;
         Attribute[] customAttributes = PseudoCustomAttribute.GetCustomAttributes(type, caType, true, out i);
         if (!inherit || (caType.IsSealed && !CustomAttribute.GetAttributeUsage(caType).Inherited))
         {
             object[] customAttributes2 = CustomAttribute.GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, i, caType, !CustomAttribute.AllowCriticalCustomAttributes(type));
             if (i > 0)
             {
                 Array.Copy(customAttributes, 0, customAttributes2, customAttributes2.Length - i, i);
             }
             return(customAttributes2);
         }
         List <object> list = new List <object>();
         bool          mustBeInheritable = false;
         Type          elementType       = (caType == null || caType.IsValueType || caType.ContainsGenericParameters) ? typeof(object) : caType;
         while (i > 0)
         {
             list.Add(customAttributes[--i]);
         }
         while (type != (RuntimeType)typeof(object) && type != null)
         {
             object[] customAttributes3 = CustomAttribute.GetCustomAttributes(type.GetRuntimeModule(), type.MetadataToken, 0, caType, mustBeInheritable, list, !CustomAttribute.AllowCriticalCustomAttributes(type));
             mustBeInheritable = true;
             for (int j = 0; j < customAttributes3.Length; j++)
             {
                 list.Add(customAttributes3[j]);
             }
             type = (type.BaseType as RuntimeType);
         }
         object[] array = CustomAttribute.CreateAttributeArrayHelper(elementType, list.Count);
         Array.Copy(list.ToArray(), 0, array, 0, list.Count);
         return(array);
     }
 }