Пример #1
0
        public static ModuleDefinition CreateModule(string name, ModuleParameters parameters)
        {
            Mixin.CheckName(name);
            Mixin.CheckParameters(parameters);

            var module = new ModuleDefinition {
                Name            = name,
                kind            = parameters.Kind,
                Runtime         = parameters.Runtime,
                architecture    = parameters.Architecture,
                mvid            = Guid.NewGuid(),
                Attributes      = ModuleAttributes.ILOnly,
                Characteristics = (ModuleCharacteristics)0x8540,
            };

            if (parameters.AssemblyResolver != null)
            {
                module.assembly_resolver = parameters.AssemblyResolver;
            }

            if (parameters.MetadataResolver != null)
            {
                module.metadata_resolver = parameters.MetadataResolver;
            }

            if (parameters.Kind != ModuleKind.NetModule)
            {
                var assembly = new AssemblyDefinition();
                module.assembly      = assembly;
                module.assembly.Name = CreateAssemblyName(name);
                assembly.main_module = module;
            }

            module.Types.Add(new TypeDefinition(string.Empty, "<Module>", TypeAttributes.NotPublic));

            return(module);
        }
Пример #2
0
 public ByReferenceType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.ByRef;
 }
Пример #3
0
 public CustomAttributeNamedArgument(string name, CustomAttributeArgument argument)
 {
     Mixin.CheckName(name);
     this.name     = name;
     this.argument = argument;
 }
Пример #4
0
 public CustomAttributeArgument(TypeReference type, object value)
 {
     Mixin.CheckType(type);
     this.type  = type;
     this.value = value;
 }
Пример #5
0
 public ArrayType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Array;
 }
Пример #6
0
 public SentinelType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Sentinel;
 }
Пример #7
0
 public PinnedType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Pinned;
 }
Пример #8
0
 public PointerType(TypeReference type)
     : base(type)
 {
     Mixin.CheckType(type);
     this.etype = MD.ElementType.Ptr;
 }
Пример #9
0
        public TypeDefinition GetType(string @namespace, string name)
        {
            Mixin.CheckName(name);

            return(((TypeDefinitionCollection)this.Types).GetType(@namespace ?? string.Empty, name));
        }