public static void SetDefaultColorSet(IConsoleColorSet colorSet) { string className = GetCallerClassName(); if (!_defaultSet.ContainsKey(className)) { _defaultSet.Add(className, colorSet); } }
public static void Write(string value, IConsoleColorSet colorSet = null, bool blockPrefix = false) { string classname = GetCallerClassName(); string methodname = GetCallerMethodName(); if (!_allowedThreadClass.Contains(classname) || !_allowedThreadMethod.Contains(methodname)) { return; } Swap(classname, colorSet); string prefix = _defaultTitle.ContainsKey(classname) ? _defaultTitle[classname] : string.Empty; Console.Write((!blockPrefix ? prefix : string.Empty) + value); SwapBack(); }
private static void Swap(string className, IConsoleColorSet colorSet = null) { IConsoleColorSet set = ConsoleColorSetDefault.Instance; if (_defaultSet.ContainsKey(className)) { set = _defaultSet[className]; } colorSet = colorSet ?? set; _bg = Console.BackgroundColor; _fg = Console.ForegroundColor; Console.BackgroundColor = colorSet.BackgroundColor; Console.ForegroundColor = colorSet.ForegroundColor; }