Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }