public void WriteValues(string indent, SearchTelemetry telemetry, AggregateManager?aggregate) { ConsoleColors colors = default; if (Options.HighlightMatch) { if (Options.ContentDisplayStyle == ContentDisplayStyle.Value || Options.ContentDisplayStyle == ContentDisplayStyle.ValueDetail) { colors = Colors.Match; } } var valueWriter = new ValueWriter( ContentTextWriter.Default, indent, includeEndingIndent: false); foreach (string value in FileValues !.Modify(Options.ModifyOptions)) { Write(indent, Verbosity.Normal); valueWriter.Write(value, Symbols, colors, Colors.MatchBoundary); WriteLine(Verbosity.Normal); aggregate?.Storage.Add(value); telemetry.MatchCount++; } }
static void Main(string[] args) { ConsoleColors.WriteHeader("Your header"); ConsoleColors.EmptyLine(); ConsoleColors.WriteGreen("TODO", false); ConsoleWaiter.ReadLineWithTimeout(); }
public static void ConsoleSetColors(ConsoleColors colors) { switch (colors) { case ConsoleColors.Active: Console.BackgroundColor = Constants.ActiveBackground; Console.ForegroundColor = Constants.ActiveText; break; case ConsoleColors.Default: Console.BackgroundColor = Constants.DefaultBackground; Console.ForegroundColor = Constants.DefaultText; break; case ConsoleColors.Inverted: Console.BackgroundColor = Constants.DefaultText; Console.ForegroundColor = Constants.DefaultBackground; break; case ConsoleColors.Interactive: Console.BackgroundColor = Constants.InteractiveBackground; Console.ForegroundColor = Constants.InteractiveText; break; case ConsoleColors.ActiveInverted: Console.BackgroundColor = Constants.ActiveText; Console.ForegroundColor = Constants.ActiveBackground; break; default: throw new ArgumentOutOfRangeException(nameof(colors), colors, null); } }
public static void WriteFileError( Exception ex, string?path = null, string?basePath = null, bool relativePath = false, ConsoleColors colors = default, string?indent = null, Verbosity verbosity = Verbosity.Normal) { if (colors.IsDefault) { colors = Colors.Message_Warning; } string message = ex.Message; WriteLine($"{indent}ERROR: {message}", colors, verbosity); if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(message) && !message.Contains(path, FileSystemHelpers.Comparison)) { Write($"{indent}PATH: ", colors, verbosity); WritePath(path, basePath, relativePath: relativePath, colors: colors, verbosity: verbosity); WriteLine(verbosity); } #if DEBUG WriteLine($"{indent}STACK TRACE:", verbosity); WriteLine(ex.StackTrace, verbosity); #endif }
/// <summary> /// </summary> /// <param name="entry"></param> public void Log(LogEntry entry) { lock (locker) { ConsoleColors colors = GetLogLevelConsoleColors(entry.Severity); switch (entry.Severity) { case LoggingEventType.Debug: System.Console.WriteLine(entry.Message, colors.Background, colors.Foreground); break; case LoggingEventType.Information: System.Console.WriteLine(entry.Message, colors.Background, colors.Foreground); break; case LoggingEventType.Warning: System.Console.WriteLine(entry.Message, colors.Background, colors.Foreground); break; case LoggingEventType.Error: System.Console.WriteLine(entry.Message, colors.Background, colors.Foreground); break; case LoggingEventType.Fatal: System.Console.WriteLine(entry.Message, colors.Background, colors.Foreground); break; } } }
static void Main(string[] args) { ConsoleColors.WriteHeader("Please enter your name within the next 5 seconds."); var userName = ReadLineWithTimeout(5); Console.Clear(); ConsoleColors.WriteSectionYellow(!string.IsNullOrWhiteSpace(userName) ? $"Hello: {userName}" : "Nothing entered", false); }
private LogMessageEntry CreateDefaultLogMessage(StringBuilder logBuilder, LogLevel logLevel, string logName, int eventId, string message, Exception exception) { // Example: // INFO: ConsoleApp.Program[10] // Request received ConsoleColors logLevelColors = GetLogLevelConsoleColors(logLevel); string logLevelString = GetLogLevelString(logLevel); // category and event id logBuilder.Append(LoglevelPadding); logBuilder.Append(logName); logBuilder.Append('['); logBuilder.Append(eventId); logBuilder.AppendLine("]"); // scope information GetScopeInformation(logBuilder, multiLine: true); if (!string.IsNullOrEmpty(message)) { // message logBuilder.Append(_messagePadding); int len = logBuilder.Length; logBuilder.AppendLine(message); logBuilder.Replace(Environment.NewLine, _newLineWithMessagePadding, len, message.Length); } // Example: // System.InvalidOperationException // at Namespace.Class.Function() in File:line X if (exception != null) { // exception message logBuilder.AppendLine(exception.ToString()); } string timestamp = null; string timestampFormat = Options.TimestampFormat; if (timestampFormat != null) { DateTime dateTime = GetCurrentDateTime(); timestamp = dateTime.ToString(timestampFormat); } return(new LogMessageEntry( message: logBuilder.ToString(), timeStamp: timestamp, levelString: logLevelString, levelBackground: logLevelColors.Background, levelForeground: logLevelColors.Foreground, messageColor: DefaultConsoleColor, logAsError: logLevel >= Options.LogToStandardErrorThreshold )); }
public void VerifyValidIgnoreCase() { var clr = new ConsoleColors(); foreach (var name in _validColorNames) { var actual = clr[name]; Assert.IsTrue(clr[name.ToLower()] == actual); Assert.IsTrue(clr[name.ToLower()] == actual); } }
static void Main(string[] args) { if (args.Length != 1) { DisplayHelp(); } else { ConsoleColors.SetConsoleColor((byte)(Enum.Parse(typeof(ConsoleColor), args[0]))); } }
/* * Write order: * 1. background color * 2. foreground color * 3. message * 4. reset foreground color * 5. reset background color */ public static bool WriteColors([NotNull] this TextWriter thisValue, ConsoleColors colors) { // compose the string to avoid race conditions string colorsText = colors.Background?.GetBackgroundColorEscapeCode() + colors.Foreground?.GetForegroundColorEscapeCode(); if (string.IsNullOrEmpty(colorsText)) { return(false); } thisValue.Write(colorsText); return(true); }
protected override void WriteSummary(SearchTelemetry telemetry, Verbosity verbosity) { WriteSearchedFilesAndDirectories(telemetry, Options.SearchTarget, verbosity); if (!ShouldLog(verbosity)) { return; } WriteLine(verbosity); string matchCount = telemetry.MatchCount.ToString("n0"); string matchingFileCount = telemetry.MatchingFileCount.ToString("n0"); string processedMatchCount = telemetry.ProcessedMatchCount.ToString("n0"); string processedFileCount = telemetry.ProcessedFileCount.ToString("n0"); const string matchesTitle = "Matches"; const string matchingFilesTitle = "Matching files"; const string replacementsTitle = "Replacements"; const string replacedFilesTitle = "Replaced files"; int width1 = Math.Max(matchesTitle.Length, replacementsTitle.Length); int width2 = Math.Max(matchCount.Length, processedMatchCount.Length); int width3 = Math.Max(matchingFilesTitle.Length, replacedFilesTitle.Length); int width4 = Math.Max(matchingFileCount.Length, processedFileCount.Length); ConsoleColors colors = Colors.Message_OK; WriteCount(matchesTitle, matchCount, width1, width2, colors, verbosity); Write(" ", colors, verbosity); int matchingLinesWidth = 0; if (telemetry.MatchingLineCount >= 0) { matchingLinesWidth += WriteCount("Matching lines", telemetry.MatchingLineCount, colors, verbosity); Write(" ", colors, verbosity); matchingLinesWidth += 2; } WriteCount(matchingFilesTitle, matchingFileCount, width3, width4, colors, verbosity); WriteLine(verbosity); colors = (Options.DryRun) ? Colors.Message_DryRun : Colors.Message_Change; WriteCount(replacementsTitle, processedMatchCount, width1, width2, colors, verbosity); Write(" ", colors, verbosity); Write(' ', matchingLinesWidth, colors, verbosity); WriteCount(replacedFilesTitle, processedFileCount, width3, width4, colors, verbosity); WriteLine(verbosity); }
public static void ConsoleSetColors(ConsoleColors colors) { switch (colors) { case ConsoleColors.Active: Console.BackgroundColor = Constants.ActiveBackground; Console.ForegroundColor = Constants.ActiveText; break; case ConsoleColors.Default: Console.BackgroundColor = Constants.DefaultBackground; Console.ForegroundColor = Constants.DefaultText; break; } }
public BoardPrinter(IEnumerable <IPiece> pieces, bool isWindows = false) { Colors = new ConsoleColors(isWindows); Tiles = new string[8, 8]; foreach (var piece in pieces) { var color = 'w'; if (!piece.IsWhite) { color = 'b'; } Set(piece.CurrentPosition, color.ToString() + piece.Identity.ToString() + " "); } }
public static void WriteGroups( GroupDefinitionCollection groupDefinitions, Dictionary <int, ConsoleColors>?colors = null, Verbosity verbosity = Verbosity.Detailed) { if (!ShouldLog(verbosity)) { return; } if (groupDefinitions.Count == 1 && groupDefinitions[0].Number == 0) { return; } WriteLine(verbosity); WriteLine("Groups:", verbosity); int maxWidth = groupDefinitions.Max(f => f.Number).GetDigitCount(); foreach (GroupDefinition groupDefinition in groupDefinitions.OrderBy(f => f.Number)) { if (groupDefinition.Number == 0) { continue; } ConsoleColors groupColors = default; colors?.TryGetValue(groupDefinition.Number, out groupColors); Write(" ", verbosity); string indexText = groupDefinition.Number.ToString(); Write(' ', maxWidth - indexText.Length, verbosity); Write(indexText, groupColors, verbosity); if (indexText != groupDefinition.Name) { Write(" ", verbosity); Write(groupDefinition.Name, groupColors, verbosity); } WriteLine(verbosity); } }
public Player(string id, string name, string url, Position position, int shootDirection, string me) { Id = id; Name = name; Url = url; Position = position; ShootDirection = shootDirection; Me = me; Destroyed = false; Wins = 0; Deaths = 0; Draws = 0; Kills = 0; RoundDestroyed = 0; ConsoleColor = ConsoleColors.GetRandomConsoleColor(); }
static async Task Main(string[] args) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); ConsoleColors.SetInitialColors(ConsoleColor.Green, ConsoleColor.Black); Console.WriteLine("Starting..."); _serviceProvider = JobDependencyInjection.Setup(); _logger = _serviceProvider.GetService <ILoggerFactory>().CreateLogger <Program>(); await SeedData(); Console.WriteLine($"Completed in {Math.Round((double)stopwatch.ElapsedMilliseconds / 1_000, 2)}s"); Console.ReadKey(); }
public void Setup() { ConsoleColors.Reset(); _p1 = new Player("1", "one", "http://test/one", new Position(1, 1), 0, "true"); _p2 = new Player("2", "two", "http://test/two", new Position(1, 1), 0, "true"); _p3 = new Player("3", "three", "http://test/three", new Position(1, 1), 0, "true"); // not explicitly added here _p4 = new Player("4", "four", "http://test/four", new Position(1, 1), 0, "true"); // not explicitly added here _players = new List <Player>(); _players.Add(_p1); _players.Add(_p2); _gameState = GameState.MakeInitialGameState( _players, new TurnCount(_turnCountDefault, _iConfigProvider), new GridSize(_gridColumnsDefault, _gridRowsDefault, _iConfigProvider), new StandardCollisions(), new StandardEndGame()); }
public void SetColors(ConsoleColors colors) { this.black.SetColor(ColorTranslator.FromHtml(colors.black)); this.darkBlue.SetColor(ColorTranslator.FromHtml(colors.darkBlue)); this.darkGreen.SetColor(ColorTranslator.FromHtml(colors.darkGreen)); this.darkCyan.SetColor(ColorTranslator.FromHtml(colors.darkCyan)); this.darkRed.SetColor(ColorTranslator.FromHtml(colors.darkRed)); this.darkMagenta.SetColor(ColorTranslator.FromHtml(colors.darkMagenta)); this.darkYellow.SetColor(ColorTranslator.FromHtml(colors.darkYellow)); this.gray.SetColor(ColorTranslator.FromHtml(colors.gray)); this.darkGray.SetColor(ColorTranslator.FromHtml(colors.darkGray)); this.blue.SetColor(ColorTranslator.FromHtml(colors.blue)); this.green.SetColor(ColorTranslator.FromHtml(colors.green)); this.cyan.SetColor(ColorTranslator.FromHtml(colors.cyan)); this.red.SetColor(ColorTranslator.FromHtml(colors.red)); this.magenta.SetColor(ColorTranslator.FromHtml(colors.magenta)); this.yellow.SetColor(ColorTranslator.FromHtml(colors.yellow)); this.white.SetColor(ColorTranslator.FromHtml(colors.white)); }
private static string ReadFromInput(bool isNumber, out uint inpLen) { ConsoleColors.SetAndPushDefaultColors(); var input = ""; char ch; inpLen = 0; while (!(ch = Console.ReadKey(true).KeyChar).Equals(Nl[0]) || inpLen.Equals(0)) { switch (ch) { case '\r': continue; case '\b' when inpLen != 0: input = input.Remove(input.Length - 1); inpLen--; Console.Write("\b \b"); break; default: { if (inpLen != 9 && ch != '\b') { if (isNumber && (ch < '0' || ch > '9')) { continue; } Console.Write(ch); input += ch; inpLen++; } break; } } } ConsoleColors.SetPreviousAndPopColors(); return(input); }
protected override void Invoke() { var configuration = new ConfigurationBuilder() .AddMasterConfiguration(force: true) .Build(); var login = configuration["Login"]; var password = configuration["Password"]; Application app = new Application(); this.Cmdlet.PurchaseList = app.GetPurchases(login, password, this.Cmdlet.Count); for (int i = 0; i < this.Cmdlet.Count; i++) { ConsoleColors.WriteInColor(this.Cmdlet.PurchaseList[i].Dealer.Name, 76, true); foreach (var item in this.Cmdlet.PurchaseList[i].Items) { ConsoleColors.WriteInColor(item.Name, 220, true); } Console.WriteLine(); } }
internal LoggerLevelMap <ConsoleColors> GetEffectiveColors() { LoggerLevelMap <ConsoleColors> result = new LoggerLevelMap <ConsoleColors>( new ConsoleColors { Foreground = null, Background = null }); foreach (var mapping in this) { foreach (var level in mapping.Level.TrueValues()) { ConsoleColors cc = result[level]; result[level] = new ConsoleColors(mapping.Foreground, mapping.Background); } } return(result); }
public ConsoleColors GetColors() { var colors = new ConsoleColors(); colors.black = ColorTranslator.ToHtml(this.black.GetColor()); colors.darkBlue = ColorTranslator.ToHtml(this.darkBlue.GetColor()); colors.darkGreen = ColorTranslator.ToHtml(this.darkGreen.GetColor()); colors.darkCyan = ColorTranslator.ToHtml(this.darkCyan.GetColor()); colors.darkRed = ColorTranslator.ToHtml(this.darkRed.GetColor()); colors.darkMagenta = ColorTranslator.ToHtml(this.darkMagenta.GetColor()); colors.darkYellow = ColorTranslator.ToHtml(this.darkYellow.GetColor()); colors.gray = ColorTranslator.ToHtml(this.gray.GetColor()); colors.darkGray = ColorTranslator.ToHtml(this.darkGray.GetColor()); colors.blue = ColorTranslator.ToHtml(this.blue.GetColor()); colors.green = ColorTranslator.ToHtml(this.green.GetColor()); colors.cyan = ColorTranslator.ToHtml(this.cyan.GetColor()); colors.red = ColorTranslator.ToHtml(this.red.GetColor()); colors.magenta = ColorTranslator.ToHtml(this.magenta.GetColor()); colors.yellow = ColorTranslator.ToHtml(this.yellow.GetColor()); colors.white = ColorTranslator.ToHtml(this.white.GetColor()); return(colors); }
public static void PrintControls() { const string line = " - "; const string tab = " "; string[] newInstanceString = { "RETURN", "compile&execute", "Q", "exit", "F", "choose file", "T/Ctr-T", "ACtest" }; _lengthOfControls = 0; for (var i = 0; i < newInstanceString.Length; i++) { _lengthOfControls += (uint)newInstanceString[i].Length; ConsoleColors.SetAndPushColors(Green); Console.Write(newInstanceString[i++]); ConsoleColors.SetPreviousAndPopColors(); ConsoleColors.SetAndPushColors(Yellow); Console.Write(line); ConsoleColors.SetPreviousAndPopColors(); _lengthOfControls += (uint)newInstanceString[i].Length; ConsoleColors.SetAndPushColors(Cyan); Console.Write(newInstanceString[i]); if (!i.Equals(newInstanceString.Length - 1)) { Console.Write(tab); } ConsoleColors.SetPreviousAndPopColors(); } _lengthOfControls += (uint)(newInstanceString.Length / 2 * line.Length + (newInstanceString.Length / 2 - 1) * tab.Length); }
protected override void WriteSummary(SearchTelemetry telemetry, Verbosity verbosity) { base.WriteSummary(telemetry, verbosity); ConsoleColors colors = (Options.DryRun) ? Colors.Message_DryRun : Colors.Message_Change; if (telemetry.ProcessedFileCount > 0) { LogHelpers.WriteCount("Moved files", telemetry.ProcessedFileCount, colors, verbosity); } if (telemetry.ProcessedDirectoryCount > 0) { if (telemetry.ProcessedFileCount > 0) { Logger.Write(" ", verbosity); } LogHelpers.WriteCount("Moved directories", telemetry.ProcessedDirectoryCount, colors, verbosity); } Logger.WriteLine(verbosity); }
private void OnNetworkReceive(NetPeer peer, NetPacketReader reader, DeliveryMethod deliveryMethod) { ConsoleColors CurrentColor = (ConsoleColors)reader.GetByte(); switch (CurrentColor) { case ConsoleColors.Message: Console.ForegroundColor = ConsoleColor.White; break; case ConsoleColors.Warning: Console.ForegroundColor = ConsoleColor.Yellow; break; case ConsoleColors.Error: Console.ForegroundColor = ConsoleColor.Red; break; } Console.WriteLine(Encoding.UTF8.GetString(reader.GetRemainingBytes())); Console.ForegroundColor = ConsoleColor.White; }
public void EnsureValidResolution() { var clr = new ConsoleColors(); Assert.That(clr.Names.Length, Is.EqualTo(16)); Assert.IsTrue(clr["Black"] == ConsoleColor.Black); Assert.IsTrue(clr["DarkBlue"] == ConsoleColor.DarkBlue); Assert.IsTrue(clr["DarkGreen"] == ConsoleColor.DarkGreen); Assert.IsTrue(clr["DarkCyan"] == ConsoleColor.DarkCyan); Assert.IsTrue(clr["DarkRed"] == ConsoleColor.DarkRed); Assert.IsTrue(clr["DarkMagenta"] == ConsoleColor.DarkMagenta); Assert.IsTrue(clr["DarkYellow"] == ConsoleColor.DarkYellow); Assert.IsTrue(clr["Gray"] == ConsoleColor.Gray); Assert.IsTrue(clr["DarkGray"] == ConsoleColor.DarkGray); Assert.IsTrue(clr["Blue"] == ConsoleColor.Blue); Assert.IsTrue(clr["Green"] == ConsoleColor.Green); Assert.IsTrue(clr["Cyan"] == ConsoleColor.Cyan); Assert.IsTrue(clr["Red"] == ConsoleColor.Red); Assert.IsTrue(clr["Magenta"] == ConsoleColor.Magenta); Assert.IsTrue(clr["Yellow"] == ConsoleColor.Yellow); Assert.IsTrue(clr["White"] == ConsoleColor.White); }
private void AddEntry(string Text, ConsoleColors TextColor) { if (ConsoleHistory.GetChildCount() >= ConsoleMaxLines) { ConsoleHistory.GetChild(0).QueueFree(); } Node ConsoleEntryNode = ConsoleEntry.Instance(); Label ConsoleEntryLabel = (Label)ConsoleEntryNode; switch (TextColor) { default: case ConsoleColors.Message: ConsoleEntryLabel.AddColorOverride("font_color", new Color(1.0f, 1.0f, 1.0f)); break; case ConsoleColors.Warning: ConsoleEntryLabel.AddColorOverride("font_color", new Color(0.988f, 0.91f, 0.012f)); break; case ConsoleColors.Error: ConsoleEntryLabel.AddColorOverride("font_color", new Color(0.988f, 0.012f, 0.012f)); break; } ConsoleEntryLabel.Text = Text; if (Sys.Ref.Shared.Contains <RCONSys>()) { Sys.Ref.Shared.GetNode <RCONSys>().Send(Text, TextColor); } ConsoleHistory.AddChild(ConsoleEntryLabel); CallDeferred(nameof(SetScrollbar)); }
protected void WritePath(SearchContext context, FileMatch fileMatch, string?baseDirectoryPath, string indent, ColumnWidths?columnWidths, ConsoleColors matchColors) { if (Options.PathDisplayStyle == PathDisplayStyle.Match && fileMatch.NameMatch != null && !object.ReferenceEquals(fileMatch.NameMatch, Match.Empty)) { if (ShouldLog(Verbosity.Minimal)) { Write(indent, Verbosity.Minimal); Write(fileMatch.NameMatch.Value, (Options.HighlightMatch) ? matchColors : default, Verbosity.Minimal);
public static void WriteProcessedFilesAndDirectories( SearchTelemetry telemetry, SearchTarget searchTarget, string processedFilesTitle, string processedDirectoriesTitle, bool dryRun, Verbosity verbosity = Verbosity.Detailed) { if (!ShouldLog(verbosity)) { return; } WriteLine(verbosity); const string filesTitle = "Matching files"; const string directoriesTitle = "Matching directories"; bool files = searchTarget != SearchTarget.Directories; bool directories = searchTarget != SearchTarget.Files; string matchingFileCount = telemetry.MatchingFileCount.ToString("n0"); string matchingDirectoryCount = telemetry.MatchingDirectoryCount.ToString("n0"); string processedFileCount = telemetry.ProcessedFileCount.ToString("n0"); string processedDirectoryCount = telemetry.ProcessedDirectoryCount.ToString("n0"); int width1 = Math.Max(filesTitle.Length, processedFilesTitle.Length); int width2 = Math.Max(matchingFileCount.Length, processedFileCount.Length); int width3 = Math.Max(directoriesTitle.Length, processedDirectoriesTitle.Length); int width4 = Math.Max(matchingDirectoryCount.Length, processedDirectoryCount.Length); ConsoleColors colors = Colors.Message_OK; if (files) { WriteCount(filesTitle, matchingFileCount, width1, width2, colors, verbosity); } if (directories) { if (files) { Write(" ", colors, verbosity); } WriteCount(directoriesTitle, matchingDirectoryCount, width3, width4, colors, verbosity); } WriteLine(verbosity); colors = (dryRun) ? Colors.Message_DryRun : Colors.Message_Change; if (files) { WriteCount(processedFilesTitle, processedFileCount, width1, width2, colors, verbosity); } if (directories) { if (files) { Write(" ", colors, verbosity); } WriteCount(processedDirectoriesTitle, processedDirectoryCount, width3, width4, colors, verbosity); } WriteLine(verbosity); }
public void WriteAggregatedValues(CancellationToken cancellationToken) { int count = 0; IEnumerable <string> values = Storage.Values; if (Sections?.Count > 1 && (ModifyOptions.HasFunction(ModifyFunctions.Except_Intersect))) { if (ModifyOptions.HasFunction(ModifyFunctions.Except)) { values = ExceptOrIntersect(Storage.Values, (x, y, c) => x.Except(y, c)); } else if (ModifyOptions.HasFunction(ModifyFunctions.Intersect)) { values = ExceptOrIntersect(Storage.Values, (x, y, c) => x.Intersect(y, c)); } } Dictionary <string, List <StorageSection> >?valuesMap = null; if (Sections?.Count > 0 && ModifyOptions.HasFunction(ModifyFunctions.Group)) { if (Options.ContentFilter != null) { valuesMap = GroupByValues(Storage.Values); } else { valuesMap = Storage.Values .Zip(Sections) .GroupBy(f => f.First) .ToDictionary(f => f.Key, f => f.Select(f => f.Second).ToList()); } values = valuesMap .Select(f => f.Key) .Modify(ModifyOptions, filter: ModifyFunctions.Enumerable & ~ModifyFunctions.Distinct); } else { values = values.Modify(ModifyOptions, filter: ModifyFunctions.Enumerable); } using (IEnumerator <string> en = values.GetEnumerator()) { if (en.MoveNext()) { OutputSymbols symbols = OutputSymbols.Create(Options.HighlightOptions); ConsoleColors colors = ((Options.HighlightOptions & HighlightOptions.Match) != 0) ? Colors.Match : default; ConsoleColors boundaryColors = (Options.HighlightBoundary) ? Colors.MatchBoundary : default; var valueWriter = new ValueWriter(new ContentTextWriter(Verbosity.Minimal), includeEndingIndent: false); if (!Options.AggregateOnly) { ConsoleOut.WriteLineIf(ShouldWriteLine(ConsoleOut.Verbosity)); Out?.WriteLineIf(ShouldWriteLine(Out.Verbosity)); } do { cancellationToken.ThrowIfCancellationRequested(); valueWriter.Write(en.Current, symbols, colors, boundaryColors); if (valuesMap != null && ShouldLog(Verbosity.Detailed)) { int groupCount = valuesMap[en.Current].Count; Write(" ", Colors.Message_OK, Verbosity.Detailed); Write(groupCount.ToString("n0"), Colors.Message_OK, Verbosity.Detailed); } WriteLine(Verbosity.Minimal); if (valuesMap != null) { WriteGroup(valuesMap[en.Current], cancellationToken); } count++; } while (en.MoveNext()); if (Options.IncludeSummary || ShouldLog(Verbosity.Detailed)) { Verbosity verbosity = (Options.IncludeSummary) ? Verbosity.Minimal : Verbosity.Detailed; if (valuesMap != null) { count = valuesMap.Sum(f => f.Value.Count); } WriteLine(verbosity); if (valuesMap != null) { WriteCount("Groups", valuesMap.Count, verbosity: verbosity); Write(" ", verbosity); } WriteCount("Values", count, verbosity: verbosity); WriteLine(verbosity); } } } bool ShouldWriteLine(Verbosity verbosity) { if (verbosity > Verbosity.Minimal) { return(true); } return(verbosity == Verbosity.Minimal && (Options.PathDisplayStyle != PathDisplayStyle.Omit || Options.IncludeSummary)); } }
public void ValidNamesWithWhitespace(string value) { var clr = new ConsoleColors(); Assert.IsNotNull(clr[value]); }
public void InvalidNames(string value) { var clr = new ConsoleColors(); Assert.IsNull(clr[value]); }