Exemplo n.º 1
0
        internal static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
        {
            int count = 0;

            Attribute[] customAttributes1 = PseudoCustomAttribute.GetCustomAttributes(assembly, caType, true, out count);
            int         token             = RuntimeAssembly.GetToken(assembly.GetNativeHandle());
            bool        isDecoratedTargetSecurityTransparent = assembly.IsAllSecurityTransparent();

            object[] customAttributes2 = CustomAttribute.GetCustomAttributes(assembly.ManifestModule as RuntimeModule, token, count, caType, isDecoratedTargetSecurityTransparent);
            if (count > 0)
            {
                Array.Copy((Array)customAttributes1, 0, (Array)customAttributes2, customAttributes2.Length - count, count);
            }
            return(customAttributes2);
        }
Exemplo n.º 2
0
        internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeAssembly target)
        {
            IList <CustomAttributeData> customAttributes = CustomAttributeData.GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));
            int num = 0;

            Attribute[] customAttributes2 = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, false, out num);
            if (num == 0)
            {
                return(customAttributes);
            }
            CustomAttributeData[] array = new CustomAttributeData[customAttributes.Count + num];
            customAttributes.CopyTo(array, num);
            for (int i = 0; i < num; i++)
            {
                array[i] = new CustomAttributeData(customAttributes2[i]);
            }
            return(Array.AsReadOnly <CustomAttributeData>(array));
        }
Exemplo n.º 3
0
        internal static IList <CustomAttributeData> GetCustomAttributesInternal(RuntimeAssembly target)
        {
            IList <CustomAttributeData> customAttributes1 = CustomAttributeData.GetCustomAttributes((RuntimeModule)target.ManifestModule, RuntimeAssembly.GetToken(target.GetNativeHandle()));
            int count = 0;

            Attribute[] customAttributes2 = PseudoCustomAttribute.GetCustomAttributes(target, typeof(object) as RuntimeType, false, out count);
            if (count == 0)
            {
                return(customAttributes1);
            }
            CustomAttributeData[] array = new CustomAttributeData[customAttributes1.Count + count];
            customAttributes1.CopyTo(array, count);
            for (int index = 0; index < count; ++index)
            {
                array[index] = new CustomAttributeData(customAttributes2[index]);
            }
            return((IList <CustomAttributeData>)Array.AsReadOnly <CustomAttributeData>(array));
        }
Exemplo n.º 4
0
 internal static bool IsDefined(RuntimeAssembly assembly, RuntimeType caType)
 {
     if (PseudoCustomAttribute.IsDefined(assembly, caType))
     {
         return(true);
     }
     return(CustomAttribute.IsCustomAttributeDefined(assembly.ManifestModule as RuntimeModule, RuntimeAssembly.GetToken(assembly.GetNativeHandle()), caType));
 }
Exemplo n.º 5
0
        internal static Attribute[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType, bool includeSecCa, out int count)
        {
            count = 0;
            bool flag = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);

            if (!flag && PseudoCustomAttribute.s_pca.GetValueOrDefault(caType) == null && !PseudoCustomAttribute.IsSecurityAttribute(caType))
            {
                return(new Attribute[0]);
            }
            List <Attribute> list = new List <Attribute>();

            if (includeSecCa && (flag || PseudoCustomAttribute.IsSecurityAttribute(caType)))
            {
                object[] array;
                PseudoCustomAttribute.GetSecurityAttributes(assembly.ManifestModule.ModuleHandle.GetRuntimeModule(), RuntimeAssembly.GetToken(assembly.GetNativeHandle()), true, out array);
                if (array != null)
                {
                    foreach (object obj in array)
                    {
                        if (caType == obj.GetType() || obj.GetType().IsSubclassOf(caType))
                        {
                            list.Add((Attribute)obj);
                        }
                    }
                }
            }
            count = list.Count;
            return(list.ToArray());
        }