Exemple #1
0
        public void SetCustomAttribute(CustomAttributeBuilder customAttributeBuilder)
        {
            switch (customAttributeBuilder.KnownCA)
            {
            case KnownCA.InAttribute:
                flags |= (short)ParameterAttributes.In;
                break;

            case KnownCA.OutAttribute:
                flags |= (short)ParameterAttributes.Out;
                break;

            case KnownCA.OptionalAttribute:
                flags |= (short)ParameterAttributes.Optional;
                break;

            case KnownCA.MarshalAsAttribute:
                FieldMarshal.SetMarshalAsAttribute(moduleBuilder, PseudoToken, customAttributeBuilder);
                flags |= (short)ParameterAttributes.HasFieldMarshal;
                break;

            default:
                moduleBuilder.SetCustomAttribute(PseudoToken, customAttributeBuilder);
                break;
            }
        }
Exemple #2
0
        public void SetCustomAttribute(CustomAttributeBuilder customAttributeBuilder)
        {
            Universe u = moduleBuilder.universe;

            if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_InAttribute)
            {
                flags |= (short)ParameterAttributes.In;
            }
            else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_OutAttribute)
            {
                flags |= (short)ParameterAttributes.Out;
            }
            else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_OptionalAttribute)
            {
                flags |= (short)ParameterAttributes.Optional;
            }
            else if (customAttributeBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_MarshalAsAttribute)
            {
                FieldMarshal.SetMarshalAsAttribute(moduleBuilder, PseudoToken, customAttributeBuilder);
                flags |= (short)ParameterAttributes.HasFieldMarshal;
            }
            else
            {
                moduleBuilder.SetCustomAttribute(PseudoToken, customAttributeBuilder);
            }
        }
Exemple #3
0
        public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
        {
            switch (customBuilder.KnownCA)
            {
            case KnownCA.FieldOffsetAttribute:
                SetOffset((int)customBuilder.DecodeBlob(this.Module.Assembly).GetConstructorArgument(0));
                break;

            case KnownCA.MarshalAsAttribute:
                FieldMarshal.SetMarshalAsAttribute(typeBuilder.ModuleBuilder, pseudoToken, customBuilder);
                attribs |= FieldAttributes.HasFieldMarshal;
                break;

            case KnownCA.NonSerializedAttribute:
                attribs |= FieldAttributes.NotSerialized;
                break;

            case KnownCA.SpecialNameAttribute:
                attribs |= FieldAttributes.SpecialName;
                break;

            default:
                typeBuilder.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
                break;
            }
        }
        public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
        {
            Universe u = this.Module.universe;

            if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_FieldOffsetAttribute)
            {
                customBuilder = customBuilder.DecodeBlob(this.Module.Assembly);
                SetOffset((int)customBuilder.GetConstructorArgument(0));
            }
            else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_InteropServices_MarshalAsAttribute)
            {
                FieldMarshal.SetMarshalAsAttribute(typeBuilder.ModuleBuilder, pseudoToken, customBuilder);
                attribs |= FieldAttributes.HasFieldMarshal;
            }
            else if (customBuilder.Constructor.DeclaringType == u.System_NonSerializedAttribute)
            {
                attribs |= FieldAttributes.NotSerialized;
            }
            else if (customBuilder.Constructor.DeclaringType == u.System_Runtime_CompilerServices_SpecialNameAttribute)
            {
                attribs |= FieldAttributes.SpecialName;
            }
            else
            {
                typeBuilder.ModuleBuilder.SetCustomAttribute(pseudoToken, customBuilder);
            }
        }