Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 internal PropertyGen(TypeGen owner, MethodAttributes attrs, Type type, string name)
 {
     this.owner = owner;
     this.attrs = attrs;
     this.type  = type;
     this.name  = name;
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        internal ConstructorGen(TypeGen owner, MethodAttributes attributes, MethodImplAttributes implFlags)
            : base(owner, null)
        {
            this.attributes = attributes;
            this.implFlags  = implFlags;

            owner.RegisterForCompletion(this);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        protected RoutineGen(TypeGen owner, Type returnType)
            : base(returnType)
        {
            this.ownerType = this.owner = owner;

            if (owner != null)
            {
                owner.RegisterForCompletion(this);
            }
        }
Ejemplo n.º 10
0
        TypeGen GetDelegateType()
        {
            if (delegateType == null)
            {
                LockSignature();
                delegateType = ImplementDelegate();
            }

            return(delegateType);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 internal void AddType(TypeGen tg)
 {
     types.Add(tg);
 }