Example #1
0
        internal MetadataOnlyAssembly(MetadataOnlyModule[] modules, string manifestFile)
        {
            MetadataOnlyAssembly.VerifyModules(modules);
            this.m_manifestModule = modules[0];
            this.m_name           = AssemblyNameHelper.GetAssemblyName(this.m_manifestModule);
            this.m_manifestFile   = manifestFile;
            MetadataOnlyModule[] metadataOnlyModuleArray = modules;
            for (int num = 0; num < (int)metadataOnlyModuleArray.Length; num++)
            {
                metadataOnlyModuleArray[num].SetContainingAssembly(this);
            }
            List <Module> modules1 = new List <Module>(modules);

            foreach (string fileNamesFromFilesTable in MetadataOnlyAssembly.GetFileNamesFromFilesTable(this.m_manifestModule, false))
            {
                if (modules1.Find((Module i) => i.Name.Equals(fileNamesFromFilesTable, StringComparison.OrdinalIgnoreCase)) != null)
                {
                    continue;
                }
                Module module = this.m_manifestModule.AssemblyResolver.ResolveModule(this, fileNamesFromFilesTable);
                if (module == null)
                {
                    throw new InvalidOperationException(MetadataStringTable.ResolverMustResolveToValidModule);
                }
                if (module.Assembly != this)
                {
                    throw new InvalidOperationException(MetadataStringTable.ResolverMustSetAssemblyProperty);
                }
                modules1.Add(module);
            }
            this.m_modules = modules1.ToArray();
        }
Example #2
0
        public override FileStream[] GetFiles(bool getResourceModules)
        {
            List <string> strs = new List <string>();

            Module[] mModules = this.m_modules;
            for (int i = 0; i < (int)mModules.Length; i++)
            {
                strs.Add(mModules[i].FullyQualifiedName);
            }
            if (getResourceModules)
            {
                string directoryName = Path.GetDirectoryName(this.m_manifestFile);
                foreach (string fileNamesFromFilesTable in MetadataOnlyAssembly.GetFileNamesFromFilesTable(this.m_manifestModule, true))
                {
                    strs.Add(Path.Combine(directoryName, fileNamesFromFilesTable));
                }
            }
            return(MetadataOnlyAssembly.ConvertFileNamesToStreams(strs.ToArray()));
        }