Ejemplo n.º 1
0
        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 IFileSystem.GetFileContent(string filename)
 {
     position = position.CreateIncrementalPosition();
     progress.Report(ProgressData.InProgress(position));
     return(filesystem.GetFileContent(filename));
 }