System.RuntimeCustomAttributeData.CreateNamedArgumentStruct C# (CSharp) Method

CreateNamedArgumentStruct() public method

public CreateNamedArgumentStruct ( string name, Type type, object value, bool isField ) : CustomAttributeNamedArgument
name string
type Type
value object
isField bool
return System.Reflection.CustomAttributeNamedArgument
        public CustomAttributeNamedArgument CreateNamedArgumentStruct(string name, Type type, object value, bool isField)
        {
            // Because C# doesn't like structs which contain object references to be referenced by pointers
            // we need to use a special MOSA compiler trick to get its address to create a pointer
            CustomAttributeNamedArgument namedArgument = new CustomAttributeNamedArgument();
            var ptr = (uint**)Intrinsic.GetValueTypeAddress(namedArgument);
            ptr[0] = (uint*)Intrinsic.GetObjectAddress(name);
            ptr[1] = (uint*)Intrinsic.GetObjectAddress(type);
            ptr[2] = (uint*)Intrinsic.GetObjectAddress(value);
            ptr[3] = (uint*)(isField ? 1 : 0);

            return namedArgument;
        }