//---------------------------------------------------------- // GetNextRequest //---------------------------------------------------------- public ApplicationMonikerRequest GetNextRequest(IAssemblyManifestImport ami) { FileType type; Uri codebase; DependentFileInfo dfi; DependentAssemblyInfo dai; // we can't do components for now. if (ami.GetFileType() == FileType.ComponentManifest) { return(null); } dfi = ami.GetNextDependentFileInfo(); if (dfi != null) { codebase = new Uri(_appBase, dfi["name"]); type = FileType.RawFile; } else { // Don't follow component dependencies. // if (ami.GetFileType() == FileType.ComponentManifest) // return null; dai = ami.GetNextDependentAssemblyInfo(); if (dai != null) { codebase = new Uri(_appBase, dai["codeBase"]); type = FileType.ComponentManifest; } else { codebase = null; type = FileType.Unknown; } } if (codebase == null) { return(null); } ApplicationMonikerRequest request = (ApplicationMonikerRequest)ApplicationMonikerRequest.Create(codebase, _appBase, _appStorePath); request.type = type; return(request); }
void IFileOperator.ProcessFile(string startDir, string relPathDir, string fileName) { IAssemblyManifestImport currAssm = null; AssemblyIdentity assmID = null; DependentAssemblyInfo[] depAssmInfoArr = null; DependentFileInfo[] depFileInfoArr = null; MGTrackerNode tempNode; string relPath = Path.Combine(relPathDir, fileName); string absPath = Path.Combine(startDir, relPath); FileInfo fInf = new FileInfo(absPath); //Console.Write("Processing " + absPath + "... "); try { currAssm = DefaultAssemblyManifestImporter.GetAssemblyManifestImport(absPath); assmID = currAssm.GetAssemblyIdentity(); depAssmInfoArr = currAssm.GetDependentAssemblyInfo(); depFileInfoArr = currAssm.GetDependentFileInfo(); } catch (BadImageFormatException bife) { // This file is a module; update hash table tempNode = (MGTrackerNode)fileTable[relPath]; if (tempNode == null) { tempNode = new MGTrackerNode(); fileTable[relPath] = tempNode; tempNode.hashKey = relPath; tempNode.installPath = relPath; appModules.Add(tempNode); } tempNode.isConfNode = true; tempNode.calcHashCode = ComputeFileHash(fInf); tempNode.size = fInf.Length; // Finished updating module entry } if (currAssm != null) { // This file is an assembly; update hash table if (!IsPlatform(assmID.PublicKeyTokenString)) // completely ignore if it's part of a platform { tempNode = (MGTrackerNode)fileTable[assmID.FullName]; if (tempNode == null) { tempNode = new MGTrackerNode(); fileTable[assmID.FullName] = tempNode; tempNode.hashKey = assmID.FullName; tempNode.assmName = assmID.Name; tempNode.isAssm = true; tempNode.nVers = assmID.Vers; tempNode.publicKeyToken = assmID.PublicKeyTokenString; appAssms.Add(tempNode); } tempNode.isConfNode = true; tempNode.installPath = relPath; tempNode.size = fInf.Length; // Finished updating assembly entry // Now we process assembly dependencies //depAssmInfoArr = currAssm.GetDependentAssemblyInfo(); foreach (DependentAssemblyInfo depAssmInfo in depAssmInfoArr) { AssemblyIdentity depAssmID = depAssmInfo.AssmID; if (!IsPlatform(depAssmID.PublicKeyTokenString)) // maybe call this "IsPlatform", "CheckPlatform" { tempNode = (MGTrackerNode)fileTable[depAssmID.FullName]; if (tempNode == null) { tempNode = new MGTrackerNode(); fileTable[depAssmID.FullName] = tempNode; tempNode.hashKey = depAssmID.FullName; tempNode.assmName = depAssmID.Name; tempNode.isAssm = true; tempNode.nVers = depAssmID.Vers; tempNode.publicKeyToken = depAssmID.PublicKeyTokenString; appAssms.Add(tempNode); } tempNode.depAssmKey = assmID.FullName; tempNode.depAssmName = assmID.Name; } } // Done with assembly dependencies // Now we process file dependencies //depFileInfoArr = currAssm.GetDependentFileInfo(); foreach (DependentFileInfo depFileInfo in depFileInfoArr) { // For the hashtable, we actually need the relative path from the application root to the file, // because we want this file entry's hash key to match the file entry that is obtained by discovering // the actual location of the file string fileHashKey = Path.Combine(relPathDir, depFileInfo.Name); tempNode = (MGTrackerNode)fileTable[fileHashKey]; if (tempNode == null) { tempNode = new MGTrackerNode(); fileTable[fileHashKey] = tempNode; tempNode.hashKey = fileHashKey; tempNode.installPath = fileHashKey; appModules.Add(tempNode); } tempNode.depAssmKey = assmID.FullName; tempNode.depAssmName = assmID.Name; } // Done with file dependencies } } //Console.WriteLine("done"); }