System.Reflection.PseudoCustomAttribute.GetCustomAttributes C# (CSharp) Method

GetCustomAttributes() static private method

static private GetCustomAttributes ( Assembly assembly, Type caType, int &count ) : System.Attribute[]
assembly Assembly
caType System.Type
count int
return System.Attribute[]
        internal static Attribute[] GetCustomAttributes(Assembly assembly, Type caType, out int count)
        {
            count = 0;

            bool all = caType == typeof(object) || caType == typeof(Attribute);

            if (!all && s_pca[caType] == null && !IsSecurityAttribute(caType))
                return new Attribute[0];

            List<Attribute> pcas = new List<Attribute>();

            if (all || IsSecurityAttribute(caType))
            {
                object[] securityAttributes;

                GetSecurityAttributes(assembly.ManifestModule.ModuleHandle, assembly.AssemblyHandle.GetToken(), out securityAttributes);
                if (securityAttributes != null)
                    foreach (object a in securityAttributes)
                        if (caType == a.GetType() || a.GetType().IsSubclassOf(caType))
                            pcas.Add((Attribute)a);
            }

            count = pcas.Count;
            return pcas.ToArray();
        }
        internal static bool IsDefined(Assembly assembly, Type caType)

Same methods

PseudoCustomAttribute::GetCustomAttributes ( Module module, Type caType, int &count ) : System.Attribute[]
PseudoCustomAttribute::GetCustomAttributes ( ParameterInfo parameter, Type caType, int &count ) : System.Attribute[]
PseudoCustomAttribute::GetCustomAttributes ( RuntimeConstructorInfo ctor, Type caType, bool includeSecCa, int &count ) : System.Attribute[]
PseudoCustomAttribute::GetCustomAttributes ( RuntimeEventInfo e, Type caType, int &count ) : System.Attribute[]
PseudoCustomAttribute::GetCustomAttributes ( RuntimeFieldInfo field, Type caType, int &count ) : System.Attribute[]
PseudoCustomAttribute::GetCustomAttributes ( RuntimeMethodInfo method, Type caType, bool includeSecCa, int &count ) : System.Attribute[]
PseudoCustomAttribute::GetCustomAttributes ( RuntimePropertyInfo property, Type caType, int &count ) : System.Attribute[]
PseudoCustomAttribute::GetCustomAttributes ( RuntimeType type, Type caType, bool includeSecCa, int &count ) : System.Attribute[]

Usage Example

        internal static object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType)
        {
            int count = 0;

            Attribute[] sourceArray      = PseudoCustomAttribute.GetCustomAttributes(parameter, caType, out count);
            object[]    destinationArray = GetCustomAttributes(parameter.GetRuntimeModule(), parameter.MetadataToken, count, caType, !AllowCriticalCustomAttributes(parameter));
            if (count > 0)
            {
                Array.Copy(sourceArray, 0, destinationArray, destinationArray.Length - count, count);
            }
            return(destinationArray);
        }
All Usage Examples Of System.Reflection.PseudoCustomAttribute::GetCustomAttributes