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

GetCustomAttributes() static private method

static private GetCustomAttributes ( RuntimeFieldInfo field, Type caType, int &count ) : System.Attribute[]
field RuntimeFieldInfo
caType System.Type
count int
return System.Attribute[]
        internal static Attribute[] GetCustomAttributes(RuntimeFieldInfo field, Type caType, out int count) 
        {
            ASSERT.PRECONDITION(field != null);
            ASSERT.PRECONDITION(caType != null);

            count = 0;

            bool all = caType == typeof(object) || caType == typeof(Attribute);
            if (!all && s_pca[caType] == null)
                return null;

            Attribute[] pcas = new Attribute[s_pcasCount];
            Attribute pca = null;

            if (all || caType == typeof(MarshalAsAttribute))
            {               
                pca = MarshalAsAttribute.GetCustomAttribute(field);
                if (pca != null) pcas[count++] = pca;
            }
            if (all || caType == typeof(FieldOffsetAttribute))
            {               
                pca = FieldOffsetAttribute.GetCustomAttribute(field);
                if (pca != null) pcas[count++] = pca;
            }
            if (all || caType == typeof(NonSerializedAttribute))
            {               
                pca = NonSerializedAttribute.GetCustomAttribute(field);
                if (pca != null) pcas[count++] = pca;
            }
            return pcas;
        }
        internal static bool IsDefined(RuntimeFieldInfo field, Type caType) 

Same methods

PseudoCustomAttribute::GetCustomAttributes ( Assembly assembly, Type caType, int &count ) : System.Attribute[]
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 ( 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