Пример #1
0
        /// <summary>
        /// Defines a new .NET module that references mscorlib version 4.0.0.0.
        /// </summary>
        /// <param name="name">The name of the module.</param>
        public ModuleDefinition(string name)
            : this(new MetadataToken(TableIndex.Module, 0))
        {
            Name = name;

            CorLibTypeFactory = CorLibTypeFactory.CreateMscorlib40TypeFactory(this);
            AssemblyReferences.Add((AssemblyReference)CorLibTypeFactory.CorLibScope);
            MetadataResolver = new DefaultMetadataResolver(new DotNetFrameworkAssemblyResolver());

            TopLevelTypes.Add(new TypeDefinition(null, "<Module>", 0));
        }
Пример #2
0
        /// <summary>
        /// Defines a new .NET module.
        /// </summary>
        /// <param name="name">The name of the module.</param>
        /// <param name="corLib">The reference to the common object runtime (COR) library that this module will use.</param>
        public ModuleDefinition(string name, AssemblyReference corLib)
            : this(new MetadataToken(TableIndex.Module, 0))
        {
            Name = name;

            var importer = new ReferenceImporter(this);

            corLib = (AssemblyReference)importer.ImportScope(corLib);

            CorLibTypeFactory = new CorLibTypeFactory(corLib);
            AssemblyReferences.Add(corLib);

            OriginalTargetRuntime = DetectTargetRuntime();
            MetadataResolver      = new DefaultMetadataResolver(CreateAssemblyResolver());

            TopLevelTypes.Add(new TypeDefinition(null, "<Module>", 0));
        }