Example #1
0
 public NestedClassEmitter(AbstractTypeEmitter maintype, String name, Type baseType, Type[] interfaces)
     : this(
         maintype,
         CreateTypeBuilder(maintype, name, TypeAttributes.Sealed | TypeAttributes.NestedPublic | TypeAttributes.Class,
                           baseType, interfaces))
 {
 }
Example #2
0
 internal MethodEmitter(AbstractTypeEmitter owner, String name,
                        MethodAttributes attributes, Type returnType,
                        params Type[] argumentTypes)
     : this(owner, name, attributes)
 {
     SetParameters(argumentTypes);
     SetReturnType(returnType);
 }
Example #3
0
 private static TypeBuilder CreateTypeBuilder(AbstractTypeEmitter maintype, string name, TypeAttributes attributes,
                                              Type baseType, Type[] interfaces)
 {
     return(maintype.TypeBuilder.DefineNestedType(
                name,
                attributes,
                baseType, interfaces));
 }
Example #4
0
        internal ConstructorEmitter(AbstractTypeEmitter maintype, params ArgumentReference[] arguments)
        {
            this.maintype = maintype;

            var args = ArgumentsUtil.InitializeAndConvert(arguments);

            builder = maintype.TypeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, args);
        }
Example #5
0
        public PropertyEmitter(AbstractTypeEmitter parentTypeEmitter, string name, PropertyAttributes attributes,
                               Type propertyType, Type[] arguments)
        {
            this.parentTypeEmitter = parentTypeEmitter;

            builder = parentTypeEmitter.TypeBuilder.DefineProperty(
                name, attributes, CallingConventions.HasThis, propertyType,
                null, null, arguments, null, null);
        }
Example #6
0
        public EventEmitter(AbstractTypeEmitter typeEmitter, string name, EventAttributes attributes, Type type)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            this.typeEmitter = typeEmitter;
            this.type        = type ?? throw new ArgumentNullException("type");
            eventBuilder     = typeEmitter.TypeBuilder.DefineEvent(name, attributes, type);
        }
Example #7
0
        internal MethodEmitter(AbstractTypeEmitter owner, String name,
                               MethodAttributes attributes, MethodInfo methodToUseAsATemplate)
            : this(owner, name, attributes)
        {
            var name2GenericType = GenericUtil.GetGenericArgumentsMap(owner);

            var returnType           = GenericUtil.ExtractCorrectType(methodToUseAsATemplate.ReturnType, name2GenericType);
            var baseMethodParameters = methodToUseAsATemplate.GetParameters();
            var parameters           = GenericUtil.ExtractParametersTypes(baseMethodParameters, name2GenericType);

            genericTypeParams = GenericUtil.CopyGenericArguments(methodToUseAsATemplate, builder, name2GenericType);
            SetParameters(parameters);
            SetReturnType(returnType);
            SetSignature(returnType, methodToUseAsATemplate.ReturnParameter, parameters, baseMethodParameters);
            DefineParameters(baseMethodParameters);
        }
Example #8
0
 internal MethodEmitter(AbstractTypeEmitter owner, String name, MethodAttributes attributes)
     : this(owner.TypeBuilder.DefineMethod(name, attributes))
 {
 }
Example #9
0
 internal TypeConstructorEmitter(AbstractTypeEmitter maintype)
     : base(maintype, maintype.TypeBuilder.DefineTypeInitializer())
 {
 }
Example #10
0
        public static Dictionary <string, GenericTypeParameterBuilder> GetGenericArgumentsMap(AbstractTypeEmitter parentEmitter)
        {
            if (parentEmitter.GenericTypeParams == null || parentEmitter.GenericTypeParams.Length == 0)
            {
                return(new Dictionary <string, GenericTypeParameterBuilder>(0));
            }

            var name2GenericType = new Dictionary <string, GenericTypeParameterBuilder>(parentEmitter.GenericTypeParams.Length);

            foreach (var genType in parentEmitter.GenericTypeParams)
            {
                name2GenericType.Add(genType.Name, genType);
            }
            return(name2GenericType);
        }
Example #11
0
 public NestedClassEmitter(AbstractTypeEmitter maintype, TypeBuilder typeBuilder)
     : base(typeBuilder)
 {
     maintype.Nested.Add(this);
 }
Example #12
0
 protected internal ConstructorEmitter(AbstractTypeEmitter maintype, ConstructorBuilder builder)
 {
     this.maintype = maintype;
     this.builder  = builder;
 }