Exemple #1
0
        // Constructor.
        internal EventBuilder(TypeBuilder type, String name,
                              EventAttributes attributes, Type eventType)
        {
            // Validate the parameters.
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            else if (eventType == null)
            {
                throw new ArgumentNullException("eventType");
            }

            // Register this item to be detached later.
            type.module.assembly.AddDetach(this);

            // Create the event.
            lock (typeof(AssemblyBuilder))
            {
                this.type        = type;
                this.privateData = ClrEventCreate
                                       (((IClrProgramItem)type).ClrHandle, name,
                                       SignatureHelper.CSToILType(type.module, eventType),
                                       attributes);
            }
        }
Exemple #2
0
        // Constructor.
        internal FieldBuilder(TypeBuilder type, String name, Type fieldType,
                              FieldAttributes attributes)
        {
            // Register this item to be detached later.
            type.module.assembly.AddDetach(this);

            // Create the field.
            lock (typeof(AssemblyBuilder))
            {
                this.type        = type;
                this.privateData = ClrFieldCreate
                                       (((IClrProgramItem)type).ClrHandle, name,
                                       SignatureHelper.CSToILType(type.module, fieldType),
                                       attributes);
            }
        }