System.RuntimeCustomAttributeData.RuntimeCustomAttributeData C# (CSharp) Method

RuntimeCustomAttributeData() public method

public RuntimeCustomAttributeData ( MetadataCAStruct customAttributeTable ) : System.Collections.Generic
customAttributeTable Mosa.Runtime.MetadataCAStruct
return System.Collections.Generic
        public RuntimeCustomAttributeData(MetadataCAStruct* customAttributeTable)
        {
            RuntimeTypeHandle typeHandle = new RuntimeTypeHandle();
            ((uint**)&typeHandle)[0] = (uint*)customAttributeTable->AttributeType;
            base.attributeType = Type.GetTypeFromHandle(typeHandle);

            // Get the metadata pointer for the enum type
            typeHandle = typeof(System.Enum).TypeHandle;
            EnumTypePtr = (MetadataTypeStruct*)((uint**)&typeHandle)[0];

            // Create temporary lists to hold the arguments
            var typedArgs = new LinkedList<CustomAttributeTypedArgument>();
            var namedArgs = new LinkedList<CustomAttributeNamedArgument>();

            for (uint i = 0; i < customAttributeTable->NumberOfArguments; i++)
            {
                // Get the argument metadata pointer
                var argument = MetadataCAStruct.GetCAArgumentAddress(customAttributeTable, i);

                // Get the argument name (if any)
                string name = null;
                if (argument->Name != null)
                {
                    name = Mosa.Runtime.Internal.InitializeMetadataString(argument->Name);
                }

                // Get the argument type
                RuntimeTypeHandle argTypeHandle = new RuntimeTypeHandle();
                ((uint**)&argTypeHandle)[0] = (uint*)argument->ArgumentType;
                var argType = Type.GetTypeFromHandle(argTypeHandle);

                // Get the argument value
                var value = ResolveArgumentValue(argument, argType);

                // If the argument has a name then its a NamedArgument, otherwise its a TypedArgument
                if (name == null)
                {
                    typedArgs.AddLast(CreateTypedArgumentStruct(argType, value));
                }
                else
                {
                    namedArgs.AddLast(CreateNamedArgumentStruct(name, argType, value, argument->IsField));
                }
            }

            // Generate arrays from the argument lists
            ctorArgs = typedArgs.ToArray();
            this.namedArgs = namedArgs.ToArray();
        }