internal SearchProgress(string path, SearchProgressKind kind, bool isDirectory, Exception?exception = null) { Path = path ?? throw new ArgumentNullException(nameof(path)); Kind = kind; Exception = exception; IsDirectory = isDirectory; }
public static void Report( this IProgress <SearchProgress> progress, string path, SearchProgressKind kind, bool isDirectory = false, Exception?exception = null) { progress.Report(new SearchProgress(path, kind, isDirectory, exception)); }
private static string GetPrefix(SearchProgressKind kind) { return(kind switch { SearchProgressKind.SearchDirectory => "[S] ", SearchProgressKind.Directory => "[D] ", SearchProgressKind.File => "[F] ", _ => throw new InvalidOperationException($"Unknown enum value '{kind}'."), });
private void WritePath(string path, SearchProgressKind kind, string?indent = null) { ReadOnlySpan <char> pathDisplay = GetPath(path); ConsoleOut.Write(indent, Colors.Path_Progress); ConsoleOut.Write(GetPrefix(kind), Colors.Path_Progress); ConsoleOut.WriteLine(pathDisplay, Colors.Path_Progress); if (FileReportMode == ProgressReportMode.Path) { Out !.Write(indent); Out.Write(GetPrefix(kind)); Out.WriteLine(pathDisplay); } }
private void WritePath(string path, SearchProgressKind kind) { if (ConsoleReportMode == ProgressReportMode.Dot) { WriteProgress(); if (FileReportMode == ProgressReportMode.Path) { WritePathToFile(path, kind, Indent); } } else if (ConsoleReportMode == ProgressReportMode.Path) { WritePath(path, kind, Indent); } else if (FileReportMode == ProgressReportMode.Path) { WritePathToFile(path, kind, Indent); } }
private void WritePathToFile(string path, SearchProgressKind kind, string?indent = null) { Out !.Write(indent); Out.Write(GetPrefix(kind)); Out.WriteLine(GetPath(path)); }