Beispiel #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();
        }
Beispiel #2
0
        public static AssemblyName GetAssemblyName(MetadataOnlyModule module)
        {
            PortableExecutableKinds portableExecutableKind;
            ImageFileMachine        imageFileMachine;
            Token assemblyToken = MetadataOnlyAssembly.GetAssemblyToken(module);
            IMetadataAssemblyImport rawImport = (IMetadataAssemblyImport)module.RawImport;

            AssemblyNameHelper.AssemblyNameFromDefitionBuilder assemblyNameFromDefitionBuilder = new AssemblyNameHelper.AssemblyNameFromDefitionBuilder(assemblyToken, module.RawMetadata, rawImport);
            AssemblyName codeBaseFromManifestModule = assemblyNameFromDefitionBuilder.CalculateName();

            codeBaseFromManifestModule.CodeBase = MetadataOnlyAssembly.GetCodeBaseFromManifestModule(module);
            module.GetPEKind(out portableExecutableKind, out imageFileMachine);
            codeBaseFromManifestModule.ProcessorArchitecture = AssemblyNameHelper.CalculateProcArchIndex(portableExecutableKind, imageFileMachine);
            return(codeBaseFromManifestModule);
        }
Beispiel #3
0
 private static void VerifyModules(MetadataOnlyModule[] modules)
 {
     if (modules == null || (int)modules.Length < 1)
     {
         throw new ArgumentException(MetadataStringTable.ManifestModuleMustBeProvided);
     }
     if (MetadataOnlyAssembly.GetAssemblyToken(modules[0]) == Token.Nil)
     {
         throw new ArgumentException(MetadataStringTable.NoAssemblyManifest);
     }
     for (int i = 1; i < (int)modules.Length; i++)
     {
         if (MetadataOnlyAssembly.GetAssemblyToken(modules[i]) != Token.Nil)
         {
             throw new ArgumentException(MetadataStringTable.ExtraAssemblyManifest);
         }
     }
 }
Beispiel #4
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()));
        }
Beispiel #5
0
        public virtual Type TryTypeForwardResolution(MetadataOnlyAssembly assembly, string fullname, bool ignoreCase)
        {
            Type type;

            using (IEnumerator <UnresolvedTypeName> enumerator = PseudoCustomAttributes.GetRawTypeForwardedToAttributes(assembly).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    UnresolvedTypeName current = enumerator.Current;
                    if (!Utility.Compare(current.TypeName, fullname, ignoreCase))
                    {
                        continue;
                    }
                    type = current.ConvertToType(assembly.TypeUniverse, assembly.ManifestModuleInternal);
                    return(type);
                }
                return(null);
            }
            return(type);
        }
 public static IEnumerable <CustomAttributeData> GetTypeForwardedToAttributes(MetadataOnlyAssembly assembly)
 {
     return(PseudoCustomAttributes.GetTypeForwardedToAttributes(assembly.ManifestModuleInternal));
 }
 internal static IEnumerable <UnresolvedTypeName> GetRawTypeForwardedToAttributes(MetadataOnlyAssembly assembly)
 {
     return(PseudoCustomAttributes.GetRawTypeForwardedToAttributes(assembly.ManifestModuleInternal));
 }
Beispiel #8
0
 public override IList <CustomAttributeData> GetCustomAttributesData()
 {
     return(this.m_manifestModule.GetCustomAttributeData(MetadataOnlyAssembly.GetAssemblyToken(this.m_manifestModule)));
 }