Exemple #1
0
        /// <summary>
        /// Outputs to the Standard Output Stream optionally using
        /// different foreground/background text colors based on the respective properties.
        /// </summary>
        /// <param name="value">The message to output.</param>
        /// <param name="tag">The message's tag.</param>
        public override void Write(string value, string tag)
        {
            var curForeColor = Console.ForegroundColor;
            var curBackColor = Console.BackgroundColor;

            if (ForeColorMap.ContainsKey(tag))
            {
                Console.ForegroundColor = ForeColorMap[tag];
            }
            if (BackColorMap.ContainsKey(tag))
            {
                Console.BackgroundColor = BackColorMap[tag];
            }

            Console.Write(value);

            Console.ForegroundColor = curForeColor;
            Console.BackgroundColor = curBackColor;
        }
Exemple #2
0
 /// <summary>
 /// A function wrapping ForeColorMap.Add(string, ConsoleColor) for use with deserialization.
 /// </summary>
 /// <param name="tag">The tag to map to the specified color.</param>
 /// <param name="color">The color to map to the specified tag.</param>
 public void MapForeColor(string tag, ConsoleColor color)
 {
     ForeColorMap.Add(tag, color);
 }