public async Task ExecuteAsync(CleanAppConfigCommand command, IProgress <ProgressData> progress = null, CancellationToken ct = default(CancellationToken)) { Guard.NotNull(command, nameof(command)); progress?.Report(ProgressData.InProgressWithoutPosition()); var projectFiles = GetCsFiles(command.Directory).ToArray(); progress?.Report(ProgressData.InProgressWithoutPosition()); var appConfigFiles = GetAppConfigFiles(command.Directory); var count = projectFiles.Length; var position = new ProgressDataPosition(0, count); foreach (var projectFile in projectFiles) { progress?.Report(ProgressData.InProgress(position)); position = position.CreateIncrementalPosition(); var path = Path.GetDirectoryName(projectFile); var appConfigFile = appConfigFiles.SingleOrDefault(file => Path.GetDirectoryName(file) == path); if (appConfigFile == null) { continue; } await HandleProjectFileAsync(projectFile, appConfigFile).ConfigureAwait(false); } progress?.Report(ProgressData.FinishedSuccessfully()); }
string[] IFileSearch.FindFilesIncludingSubdirectories(string rootPath, string mask) { var result = fileSearch.FindFilesIncludingSubdirectories(rootPath, mask); foundFileCount = result.Length; currentIndex = 0; position = new ProgressDataPosition(currentIndex, foundFileCount); return(result); }
internal ProgressCommandExecution( [NotNull] IFileSystem filesystem, [NotNull] IFileSearch fileSearch, [NotNull] IProgress <ProgressData> progress) { Guard.NotNull(filesystem, nameof(filesystem)); Guard.NotNull(fileSearch, nameof(fileSearch)); Guard.NotNull(progress, nameof(progress)); this.filesystem = filesystem; this.fileSearch = fileSearch; this.progress = progress; foundFileCount = 0; position = new ProgressDataPosition(0, 0); }
string IFileSystem.GetFileContent(string filename) { position = position.CreateIncrementalPosition(); progress.Report(ProgressData.InProgress(position)); return(filesystem.GetFileContent(filename)); }