TypeGen ImplementDelegate() { TypeGen tg = new TypeGen(owner, name, attrs, typeof(MulticastDelegate), Type.EmptyTypes); ConstructorBuilder cb = tg.Public.RuntimeImpl.Constructor() .Parameter(typeof(object), "object") .Parameter(typeof(IntPtr), "method") .GetConstructorBuilder(); cb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); MethodBuilder mb = tg.Public.Virtual.RuntimeImpl.Method(typeof(IAsyncResult), "BeginInvoke") .CopyParameters(Parameters) .UncheckedParameter(typeof(AsyncCallback), "callback") .UncheckedParameter(typeof(object), "object") .GetMethodBuilder(); mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); mb = tg.Public.Virtual.RuntimeImpl.Method(ReturnType, "EndInvoke") .Parameter(typeof(IAsyncResult), "result") .GetMethodBuilder(); mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); mb = tg.Public.Virtual.RuntimeImpl.Method(ReturnType, "Invoke") .CopyParameters(Parameters) .GetMethodBuilder(); mb.SetImplementationFlags(MethodImplAttributes.Runtime | MethodImplAttributes.Managed); AttributeGen.ApplyList(ref customAttributes, tg.TypeBuilder.SetCustomAttribute); return(tg); }
internal PropertyGen(TypeGen owner, MethodAttributes attrs, Type type, string name) { this.owner = owner; this.attrs = attrs; this.type = type; this.name = name; }
internal MethodGen(TypeGen owner, string name, MethodAttributes attributes, Type returnType, MethodImplAttributes implFlags) : base(owner, returnType) { this.name = name; this.attributes = owner.PreprocessAttributes(this, attributes); this.implFlags = implFlags; }
public TypeGen Interface(string name, params Type[] interfaces) { TypeGen tg = new TypeGen(this, Qualify(name), (attrs | TypeAttributes.Interface | TypeAttributes.Abstract) & ~(TypeAttributes.Sealed | TypeAttributes.BeforeFieldInit), null, interfaces); attrs = 0; return(tg); }
public TypeGen Struct(string name, params Type[] interfaces) { TypeGen tg = new TypeGen(this, Qualify(name), (attrs | TypeAttributes.Sealed | TypeAttributes.SequentialLayout) ^ TypeAttributes.BeforeFieldInit, typeof(ValueType), interfaces); attrs = 0; return(tg); }
public TypeGen Class(string name, Type baseType, params Type[] interfaces) { TypeGen tg = new TypeGen(this, Qualify(name), (attrs | TypeAttributes.Class) ^ TypeAttributes.BeforeFieldInit, baseType, interfaces); attrs = 0; return(tg); }
internal ConstructorGen(TypeGen owner, MethodAttributes attributes, MethodImplAttributes implFlags) : base(owner, null) { this.attributes = attributes; this.implFlags = implFlags; owner.RegisterForCompletion(this); }
internal FieldGen(TypeGen owner, string name, Type type, FieldAttributes attrs) { this.owner = owner; this.attrs = attrs; this.name = name; this.type = type; fb = owner.TypeBuilder.DefineField(name, type, attrs); owner.RegisterForCompletion(this); }
protected RoutineGen(TypeGen owner, Type returnType) : base(returnType) { this.ownerType = this.owner = owner; if (owner != null) { owner.RegisterForCompletion(this); } }
TypeGen GetDelegateType() { if (delegateType == null) { LockSignature(); delegateType = ImplementDelegate(); } return(delegateType); }
internal EventGen(TypeGen owner, string name, Type type, MethodAttributes mthAttr) { this.owner = owner; this.name = name; this.type = type; this.attrs = mthAttr; eb = owner.TypeBuilder.DefineEvent(name, EventAttributes.None, type); owner.RegisterForCompletion(this); }
internal TypeGen(TypeGen owner, string name, TypeAttributes attrs, Type baseType, Type[] interfaces) { this.owner = owner.owner; this.name = name; this.baseType = baseType; this.interfaces = interfaces; tb = owner.TypeBuilder.DefineNestedType(name, attrs, baseType, interfaces); owner.nestedTypes.Add(this); ScanMethodsToImplement(interfaces); TypeInfo.RegisterProvider(tb, this); }
public TypeGen Struct(string name, params Type[] interfaces) { if (tb.IsInterface) { throw new InvalidOperationException(Properties.Messages.ErrInterfaceNoNested); } if (typeVis == 0) { typeVis |= TypeAttributes.NestedPrivate; } TypeGen tg = new TypeGen(this, name, (typeVis | typeVirt | typeFlags | TypeAttributes.Sealed | TypeAttributes.SequentialLayout) ^ TypeAttributes.BeforeFieldInit, typeof(ValueType), interfaces); ResetAttrs(); return(tg); }
public TypeGen Class(string name, Type baseType, params Type[] interfaces) { if (tb.IsInterface) { throw new InvalidOperationException(Properties.Messages.ErrInterfaceNoNested); } if (typeVis == 0) { typeVis |= TypeAttributes.NestedPrivate; } TypeGen tg = new TypeGen(this, name, (typeVis | typeVirt | typeFlags | TypeAttributes.Class) ^ TypeAttributes.BeforeFieldInit, baseType, interfaces); ResetAttrs(); return(tg); }
internal void AddType(TypeGen tg) { types.Add(tg); }