Esempio n. 1
0
 internal SearchProgress(string path, SearchProgressKind kind, bool isDirectory, Exception?exception = null)
 {
     Path        = path ?? throw new ArgumentNullException(nameof(path));
     Kind        = kind;
     Exception   = exception;
     IsDirectory = isDirectory;
 }
Esempio n. 2
0
 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));
 }
Esempio n. 3
0
 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}'."),
     });
Esempio n. 4
0
        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);
            }
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
 private void WritePathToFile(string path, SearchProgressKind kind, string?indent = null)
 {
     Out !.Write(indent);
     Out.Write(GetPrefix(kind));
     Out.WriteLine(GetPath(path));
 }