public Package Tokenise(Package package, string token) { this.TokeniseDirectoriesAndFiles(package, token); this.TokeniseFileContent(package, token); return package; }
public Package Build(Package package) { package.ClonedPath = Path.Combine(Path.Combine(FilePaths.TemporaryPackageRepository, package.Manifest.Id.ToString()), "Cloned"); package.TemplatePath = Path.Combine(Path.Combine(FilePaths.TemporaryPackageRepository, package.Manifest.Id.ToString()), "Template"); var manifestFilePath = this.PersistManifestFileAndReturnLocation(package); int progress = 0; int fileCount = package.Manifest.Files.Count; Parallel.ForEach( package.Manifest.Files, file => { var clonedPath = Path.Combine(package.ClonedPath, file.File); this.cloneFileProcessor.Process(Path.Combine(package.Manifest.Path, file.File), clonedPath); file.File = clonedPath; this.progressNotifier.UpdateProgress(ProgressStage.ClonePackage, fileCount, progress); progress++; }); // Add the manifest file so that it will be tokenised. package.Manifest.Files.Add(new ManifestFile { File = manifestFilePath }); return package; }
public Package Tokenise(Package package, Dictionary<string, string> tokens) { this.TokeniseDirectoriesAndFiles(package, tokens); this.TokeniseFileContent(package, tokens); return package; }
public void Execute(Package package) { this.manifest = package.Manifest; int progress = 0; Parallel.ForEach( package.Manifest.Files, manifestFile => { progress++; // Set destination to the Package default, unless the file has an override defined string destFilePath = this.GetDestFilePath(manifestFile); if (!Directory.Exists(Path.GetDirectoryName(destFilePath))) { Directory.CreateDirectory(Path.GetDirectoryName(destFilePath)); } this.archiveProcessor.Extract(this.manifest.Path, manifestFile.File, destFilePath); this.progressNotifier.UpdateProgress( ProgressStage.ExtractFilesFromPackage, this.manifest.Files.Count, progress); }); }
private string PersistManifestFileAndReturnLocation(Package package) { var manifestFilePath = Path.Combine(package.ClonedPath, "manifest.xml"); ManifestFactory.Save(manifestFilePath, package.Manifest); return manifestFilePath; }
public void Execute(Package package) { this.manifest = package.Manifest; foreach (var file in this.manifest.Files) { file.InstallPath = this.GetDestFilePath(file); } this.archiveProcessor.Extract(this.manifest.Path, package.Manifest.Files); }
public Package Get(string path) { Manifest manifest; using (var manifestXmlStream = this.archiveProcessor.Extract(path, "manifest.xml")) { var serializer = new XmlSerializer(typeof(Manifest)); manifest = (Manifest)serializer.Deserialize(manifestXmlStream); } manifest.Path = path; var package = new Package { Manifest = manifest }; return package; }
private void TokeniseDirectoriesAndFiles(Package package, string token) { int progress = 0; int fileCount = package.Manifest.Files.Count; Parallel.ForEach( package.Manifest.Files, manifestFile => { var tokenisedName = Replace(token, manifestFile.File); tokenisedName = this.RebaseToTemplatePath(package, tokenisedName); this.renameFileProcessor.Process(manifestFile.File, tokenisedName); manifestFile.File = tokenisedName; this.progressNotifier.UpdateProgress(ProgressStage.TokenisePackageStructure, fileCount, progress); progress++; }); }
public void Build(Package package, string path) { var archiveName = package.Manifest.Name.ToLowerInvariant().Replace(" ", "-") + "-v" + package.Manifest.Version; var archive = Path.Combine(FilePaths.PackageRepository, archiveName) + FileTypes.Package; var file = new FileInfo(Assembly.GetExecutingAssembly().Location); SevenZipCompressor.SetLibraryPath(Path.Combine(file.DirectoryName, "7z.dll")); var sevenZipCompressor = new SevenZipCompressor { ArchiveFormat = OutArchiveFormat.SevenZip, CompressionLevel = CompressionLevel.Ultra }; sevenZipCompressor.Compressing += this.Compressing; sevenZipCompressor.CompressionFinished += this.CompressingFinished; sevenZipCompressor.CompressFiles(archive, package.Manifest.Files.Select(manifestFile => manifestFile.File).ToArray()); }
private void TokeniseFileContent(Package package, string token) { int progress = 0; int fileCount = package.Manifest.Files.Count; var processableFiles = this.binaryFileFilter.Filter(package.Manifest.Files); Parallel.ForEach( processableFiles, manifestFile => { var contents = this.fileContentProcessor.ReadContents(manifestFile.File); contents = Replace(token, contents); this.fileContentProcessor.WriteContents(manifestFile.File, contents); this.progressNotifier.UpdateProgress(ProgressStage.TokenisePackageContents, fileCount, progress); progress++; }); }
public void Remove(Package package) { this.artefactProcessor.RemoveFile(package.Manifest.Path); }
public void Remove(Package package) { this.packageRepository.Remove(package); this.Packages.Remove(package); this.NotifyOfPropertyChange(() => this.Packages); }
private string RebaseToTemplatePath(Package package, string tokenisedName) { return tokenisedName.Replace(package.ClonedPath, package.TemplatePath); }
private void TokeniseDirectoriesAndFiles(Package package, Dictionary<string, string> tokens) { var progress = 0; var fileCount = package.Manifest.Files.Count; Parallel.ForEach( package.Manifest.Files, manifestFile => { var tokenisedName = ReplaceInPath(tokens, manifestFile.File, package.ClonedPath); tokenisedName = RebaseToTemplatePath(package, tokenisedName); this.renameFileProcessor.Process(manifestFile.File, tokenisedName); manifestFile.File = tokenisedName; this.progressNotifier.UpdateProgress( ProgressStage.TokenisePackageStructure, fileCount, progress); progress++; }); }