//---------------------------------------------------------- // GetNextDependentAssemblyInfo //---------------------------------------------------------- public DependentAssemblyInfo GetNextDependentAssemblyInfo() { if (_xPathAssemblyIterator == null) { XPathNavigator myXPathNavigator = _xmlDocument.CreateNavigator(); _xPathAssemblyIterator = myXPathNavigator.Select("/assembly/dependency/dependentAssembly"); } if (_xPathAssemblyIterator.MoveNext() == false) { return(null); } XPathNodeIterator asmIter = _xPathAssemblyIterator.Current.Select("assemblyIdentity"); asmIter.MoveNext(); DependentAssemblyInfo dai = new DependentAssemblyInfo(); dai.assemblyIdentity = XMLToAssemblyId(asmIter); XPathNodeIterator installIter = _xPathAssemblyIterator.Current.Select("install"); installIter.MoveNext(); dai["codeBase"] = installIter.Current.GetAttribute("codebase", ""); return(dai); }
public static IAssemblyManifestImport GetAssemblyManifestImport(string fileName) { DefaultAssemblyManifestImport retVal = null; AssemblyManifestParser amp = new AssemblyManifestParser(); string fullPath = Path.GetFullPath(fileName); if (!File.Exists(fileName)) { throw new FileNotFoundException("The path " + fullPath + " does not refer to a file."); } else { bool checkInit = amp.InitFromFile(fileName); if (checkInit) { AssemblyIdentity impAssmID = amp.GetAssemblyIdentity(); int numDepAssms = amp.GetNumDependentAssemblies(); DependentAssemblyInfo[] impDepAssmInfoArr = new DependentAssemblyInfo[numDepAssms]; for (int i = 0; i < numDepAssms; i++) { impDepAssmInfoArr[i] = amp.GetDependentAssemblyInfo(i); if (impDepAssmInfoArr[i] == null) { throw new BadImageFormatException("Cannot access dependent assembly information from " + fullPath); } } int numDepFiles = amp.GetNumDependentFiles(); DependentFileInfo[] impDepFileInfoArr = new DependentFileInfo[numDepFiles]; for (int i = 0; i < numDepFiles; i++) { impDepFileInfoArr[i] = amp.GetDependentFileInfo(i); if (impDepFileInfoArr[i] == null) { throw new BadImageFormatException("Cannot access dependent file information from " + fullPath); } } retVal = new DefaultAssemblyManifestImport(impAssmID, impDepAssmInfoArr, impDepFileInfoArr); } else { throw new BadImageFormatException("The file " + fullPath + " is not an assembly."); } } return(retVal); }
/* * //---------------------------------------------------------- * // GetNextDependentFileInfo * //---------------------------------------------------------- * public DependentFileInfo GetNextDependentFileInfo() * { * if (_dependentFiles == null) * _dependentFiles = _assembly.GetFiles(); * * if (_fileCount >= _dependentFiles.Length) * return null; * * Uri fileUri = new Uri(_dependentFiles[_fileCount].Name); * if (String.Compare(fileUri.ToString(), _manifestUri.ToString(), true) == 0) * _fileCount++; * * if (_fileCount >= _dependentFiles.Length) * return null; * * DependentFileInfo dfi = new DependentFileInfo(); * * dfi.fileName = _dependentFiles[_fileCount].Name; * dfi.fileHash = null; // damn, we have to fix this!!!! * _fileCount++; * return dfi; * } */ //---------------------------------------------------------- // GetNextDependentAssemblyInfo //---------------------------------------------------------- public DependentAssemblyInfo GetNextDependentAssemblyInfo() { if (_dependentAssemblies == null) { _dependentAssemblies = _assembly.GetReferencedAssemblies(); } if (_assemblyCount >= _dependentAssemblies.Length) { return(null); } DependentAssemblyInfo dai = new DependentAssemblyInfo(); dai.assemblyIdentity = NameToAssemblyIdentity(_dependentAssemblies[_assemblyCount]); dai["codeBase"] = _dependentAssemblies[_assemblyCount].CodeBase; _assemblyCount++; return(dai); }