GetSecurityAttributes() static private method

static private GetSecurityAttributes ( ModuleHandle module, int token, object &securityAttributes ) : void
module System.ModuleHandle
token int
securityAttributes object
return void
Esempio n. 1
0
        internal static Attribute[] GetCustomAttributes(RuntimeConstructorInfo ctor, 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(ctor.Module.ModuleHandle.GetRuntimeModule(), ctor.MetadataToken, false, 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());
        }
Esempio n. 2
0
        internal static Attribute[] GetCustomAttributes(RuntimeType type, 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 (flag || caType == (RuntimeType)typeof(SerializableAttribute))
            {
                Attribute customAttribute = SerializableAttribute.GetCustomAttribute(type);
                if (customAttribute != null)
                {
                    list.Add(customAttribute);
                }
            }
            if (flag || caType == (RuntimeType)typeof(ComImportAttribute))
            {
                Attribute customAttribute = ComImportAttribute.GetCustomAttribute(type);
                if (customAttribute != null)
                {
                    list.Add(customAttribute);
                }
            }
            if (includeSecCa && (flag || PseudoCustomAttribute.IsSecurityAttribute(caType)) && !type.IsGenericParameter && type.GetElementType() == null)
            {
                if (type.IsGenericType)
                {
                    type = (RuntimeType)type.GetGenericTypeDefinition();
                }
                object[] array;
                PseudoCustomAttribute.GetSecurityAttributes(type.Module.ModuleHandle.GetRuntimeModule(), type.MetadataToken, false, 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());
        }
Esempio n. 3
0
        internal static Attribute[] GetCustomAttributes(RuntimeMethodInfo method, 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) == (RuntimeType)null && !PseudoCustomAttribute.IsSecurityAttribute(caType))
            {
                return(new Attribute[0]);
            }
            List <Attribute> attributeList = new List <Attribute>();

            if (flag || caType == (RuntimeType)typeof(DllImportAttribute))
            {
                Attribute customAttribute = DllImportAttribute.GetCustomAttribute(method);
                if (customAttribute != null)
                {
                    attributeList.Add(customAttribute);
                }
            }
            if (flag || caType == (RuntimeType)typeof(PreserveSigAttribute))
            {
                Attribute customAttribute = PreserveSigAttribute.GetCustomAttribute(method);
                if (customAttribute != null)
                {
                    attributeList.Add(customAttribute);
                }
            }
            if (includeSecCa && (flag || PseudoCustomAttribute.IsSecurityAttribute(caType)))
            {
                object[] securityAttributes;
                PseudoCustomAttribute.GetSecurityAttributes(method.Module.ModuleHandle.GetRuntimeModule(), method.MetadataToken, false, out securityAttributes);
                if (securityAttributes != null)
                {
                    foreach (object obj in securityAttributes)
                    {
                        if ((Type)caType == obj.GetType() || obj.GetType().IsSubclassOf((Type)caType))
                        {
                            attributeList.Add((Attribute)obj);
                        }
                    }
                }
            }
            count = attributeList.Count;
            return(attributeList.ToArray());
        }