public EventGen WithStandardImplementation() { if ((object)handler == null) { if (IsStatic) { handler = owner.Private.Static.Field(type, name); } else { handler = owner.Private.Field(type, name); } CodeGen g = AddMethod(); g.AssignAdd(handler, g.Arg("handler")); adder.GetMethodBuilder().SetImplementationFlags(MethodImplAttributes.IL | MethodImplAttributes.Managed | MethodImplAttributes.Synchronized); g = RemoveMethod(); g.AssignSubtract(handler, g.Arg("handler")); remover.GetMethodBuilder().SetImplementationFlags(MethodImplAttributes.IL | MethodImplAttributes.Managed | MethodImplAttributes.Synchronized); } ; return(this); }
public FieldGen Field(Type type, string name, Operand initialValue) { FieldGen fld = Field(type, name); CodeGen initCode = fld.IsStatic ? StaticConstructor().GetCode(): CommonConstructor().GetCode(); initCode.Assign(fld, initialValue); return(fld); }
public PropertyGen SimpleProperty(FieldGen field, string name) { if ((object)field == null) { throw new ArgumentNullException("field"); } PropertyGen pg = Property(field.Type, name); pg.Getter().GetCode().Return(field); pg.Setter().GetCode().Assign(field, pg.Setter().GetCode().PropertyValue()); return(pg); }
public FieldGen Field(Type type, string name) { if (tb.IsInterface) { throw new InvalidOperationException(Properties.Messages.ErrInterfaceNoField); } if (fldVis == 0) { fldVis |= FieldAttributes.Private; } FieldGen fld = new FieldGen(this, name, type, fldVis | fldFlags); fields.Add(fld); ResetAttrs(); return(fld); }
public FieldGen Field(Type type, string name) { if (TypeBuilder.IsInterface) { throw new InvalidOperationException(Messages.ErrInterfaceNoField); } if (_fldVis == 0) { _fldVis |= FieldAttributes.Private; } FieldGen fld = new FieldGen(this, name, type, _fldVis | _fldFlags); _fields.Add(fld); ResetAttrs(); return(fld); }
public FieldGen PublicField(Type type, string name) { if (tb.IsInterface) { throw new InvalidOperationException("Interface cannot have fields"); } if (fldVis == 0) { fldVis |= FieldAttributes.Public; } FieldGen fld = new FieldGen(this, name, type, fldVis | fldFlags); fields.Add(fld); ResetAttrs(); return(fld); }
public EventGen WithStandardImplementation() { if ((object)_handler == null) { if (IsStatic) _handler = _owner.Private.Static.Field(_type, Name); else _handler = _owner.Private.Field(_type, Name); CodeGen g = AddMethod(); g.AssignAdd(_handler, g.Arg("handler")); _adder.GetMethodBuilder().SetImplementationFlags(MethodImplAttributes.IL | MethodImplAttributes.Managed | MethodImplAttributes.Synchronized); g = RemoveMethod(); g.AssignSubtract(_handler, g.Arg("handler")); _remover.GetMethodBuilder().SetImplementationFlags(MethodImplAttributes.IL | MethodImplAttributes.Managed | MethodImplAttributes.Synchronized); }; return this; }