System.Reflection.MetadataImport.EnumCustomAttributesCount C# (CSharp) Method

EnumCustomAttributesCount() public method

public EnumCustomAttributesCount ( int mdToken ) : int
mdToken int
return int
        public int EnumCustomAttributesCount(int mdToken) 
        {
            return EnumCount((int)MetadataTokenType.CustomAttribute, mdToken);
        }

Usage Example

Esempio n. 1
0
        internal static unsafe CustomAttributeRecord[] GetCustomAttributeRecords(RuntimeModule module, int targetToken)
        {
            MetadataImport metadataImport = module.MetadataImport;
            int            count          = metadataImport.EnumCustomAttributesCount(targetToken);
            int *          result         = (int *)stackalloc byte[(((IntPtr)count) * 4)];

            metadataImport.EnumCustomAttributes(targetToken, result, count);
            CustomAttributeRecord[] recordArray = new CustomAttributeRecord[count];
            for (int i = 0; i < count; i++)
            {
                metadataImport.GetCustomAttributeProps(result[i], out recordArray[i].tkCtor.Value, out recordArray[i].blob);
            }
            return(recordArray);
        }