Пример #1
0
 public EmitTypeBuilder(EmitAssembly assembly, string ns, string name, EmitTypeKind kind, EmitType declaringType, 
     EmitVisibility visibility, EmitTypeReference baseType, Func<EmitType, IReadOnlyList<EmitTypeReference>> implementedInterfacesFactory,
     bool isAbstract, bool isSealed
 )
     : base(assembly, ns, name, kind, declaringType, 
         result => ((EmitTypeBuilder)result).memberBuilders = new List<EmitMemberReference>(), 
         visibility, baseType, implementedInterfacesFactory, isAbstract, isSealed)
 {
 }
Пример #2
0
 public EmitTypeBuilder(EmitAssembly assembly, string ns, string name, EmitTypeKind kind, EmitType declaringType,
                        EmitVisibility visibility, EmitTypeReference baseType, Func <EmitType, IReadOnlyList <EmitTypeReference> > implementedInterfacesFactory,
                        bool isAbstract, bool isSealed
                        ) :
     base(assembly, ns, name, kind, declaringType,
          result => ((EmitTypeBuilder)result).memberBuilders = new List <EmitMemberReference>(),
          visibility, baseType, implementedInterfacesFactory, isAbstract, isSealed)
 {
 }
Пример #3
0
 public EmitArrayType(EmitAssembly assembly, string ns, string name, EmitTypeKind kind, EmitType declaringType, 
     Func<EmitType, IReadOnlyList<EmitMemberReference>> membersFactory, EmitTypeReference baseType, 
     EmitType elementType, int rank
 )
     : base(assembly, ns, name, kind, declaringType, membersFactory, elementType.Visibility, baseType, _ => new List<EmitTypeReference>(), true, true)
 {
     ElementType = elementType;
     Rank = rank;
 }
Пример #4
0
 public EmitArrayType(EmitAssembly assembly, string ns, string name, EmitTypeKind kind, EmitType declaringType,
                      Func <EmitType, IReadOnlyList <EmitMemberReference> > membersFactory, EmitTypeReference baseType,
                      EmitType elementType, int rank
                      ) :
     base(assembly, ns, name, kind, declaringType, membersFactory, elementType.Visibility, baseType, _ => new List <EmitTypeReference>(), true, true)
 {
     ElementType = elementType;
     Rank        = rank;
 }
Пример #5
0
 public EmitTypeBuilder DefineType(string ns, string name, EmitTypeKind kind = EmitTypeKind.Class, 
     EmitVisibility visibility = EmitVisibility.Public, EmitTypeReference baseType = null, 
     IReadOnlyList<EmitTypeReference> implementedInterfaces = null, bool isAbstract = false,
     bool isSealed = false)
 {
     baseType = baseType ?? typeof(object);
     var typeBuilder = new EmitTypeBuilder(this, ns, name, kind, null, visibility, baseType, result => implementedInterfaces ?? new List<EmitTypeReference>(), isAbstract, isSealed);
     typeBuilders.Add(new EmitTypeReference(() => typeBuilder));
     return typeBuilder;
 }
Пример #6
0
        public EmitTypeBuilder DefineType(string ns, string name, EmitTypeKind kind = EmitTypeKind.Class,
                                          EmitVisibility visibility = EmitVisibility.Public, EmitTypeReference baseType   = null,
                                          IReadOnlyList <EmitTypeReference> implementedInterfaces = null, bool isAbstract = false,
                                          bool isSealed = false)
        {
            baseType = baseType ?? typeof(object);
            var typeBuilder = new EmitTypeBuilder(this, ns, name, kind, null, visibility, baseType, result => implementedInterfaces ?? new List <EmitTypeReference>(), isAbstract, isSealed);

            typeBuilders.Add(new EmitTypeReference(() => typeBuilder));
            return(typeBuilder);
        }
Пример #7
0
        public static TypeAttributes ToTypeAttributes(EmitTypeKind kind, EmitVisibility visibility, bool isNested, bool isAbstract, bool isSealed)
        {
            TypeAttributes result = 0;

            switch (kind)
            {
            case EmitTypeKind.Class:
                result |= TypeAttributes.Class;
                break;

            case EmitTypeKind.Interface:
                result |= TypeAttributes.Interface;
                break;
//                case EmitTypeKind.Struct:
//                    result |=
            }
            switch (visibility)
            {
            case EmitVisibility.Public:
                result |= isNested ? TypeAttributes.NestedPublic : TypeAttributes.Public;
                break;

            case EmitVisibility.Internal:
                result |= isNested ? TypeAttributes.NestedAssembly : TypeAttributes.NotPublic;
                break;

            case EmitVisibility.Private:
                result |= TypeAttributes.NestedPrivate;
                break;

            case EmitVisibility.Protected:
                result |= TypeAttributes.NestedFamily;
                break;

            case EmitVisibility.ProtectedInternal:
                result |= TypeAttributes.NestedFamORAssem;
                break;
            }
            if (isAbstract)
            {
                result |= TypeAttributes.Abstract;
            }
            if (isSealed)
            {
                result |= TypeAttributes.Sealed;
            }

            return(result);
        }
Пример #8
0
        public EmitType(EmitAssembly assembly, string ns, string name, EmitTypeKind kind, EmitType declaringType,
                        Func <EmitType, IReadOnlyList <EmitMemberReference> > membersFactory, EmitVisibility visibility,
                        EmitTypeReference baseType,
                        Func <EmitType, IReadOnlyList <EmitTypeReference> > implementedInterfacesFactory,
                        bool isAbstract, bool isSealed
                        ) :
            base(declaringType, name)
        {
            Assembly              = assembly;
            Namespace             = ns;
            Members               = new ReadOnlyListWrapper <EmitMemberReference, EmitMember>(membersFactory(this));
            Visibility            = visibility;
            Kind                  = kind;
            IsAbstract            = isAbstract;
            IsSealed              = isSealed;
            ImplementedInterfaces = new ReadOnlyListWrapper <EmitTypeReference, EmitType>(implementedInterfacesFactory(this));

            this.baseType = baseType;
        }
Пример #9
0
        public static TypeAttributes ToTypeAttributes(EmitTypeKind kind, EmitVisibility visibility, bool isNested, bool isAbstract, bool isSealed)
        {
            TypeAttributes result = 0;
            switch (kind)
            {
                case EmitTypeKind.Class:
                    result |= TypeAttributes.Class;
                    break;
                case EmitTypeKind.Interface:
                    result |= TypeAttributes.Interface;
                    break;
            //                case EmitTypeKind.Struct:
            //                    result |=
            }
            switch (visibility)
            {
                case EmitVisibility.Public:
                    result |= isNested ? TypeAttributes.NestedPublic : TypeAttributes.Public;
                    break;
                case EmitVisibility.Internal:
                    result |= isNested ? TypeAttributes.NestedAssembly : TypeAttributes.NotPublic;
                    break;
                case EmitVisibility.Private:
                    result |= TypeAttributes.NestedPrivate;
                    break;
                case EmitVisibility.Protected:
                    result |= TypeAttributes.NestedFamily;
                    break;
                case EmitVisibility.ProtectedInternal:
                    result |= TypeAttributes.NestedFamORAssem;
                    break;
            }
            if (isAbstract)
                result |= TypeAttributes.Abstract;
            if (isSealed)
                result |= TypeAttributes.Sealed;

            return result;
        }