Esempio n. 1
0
        /// <summary>
        /// Create an instance of the console provider
        /// </summary>
        /// <param name="errorColor">error color (default red)</param>
        /// <param name="warningColor">warning color (default yellow)</param>
        public ConsoleProvider(ConsoleColor errorColor = ConsoleColor.Red, ConsoleColor warningColor = ConsoleColor.Yellow)
        {
            m_history    = new List <StringBuilder>();
            m_activeLine = new StringBuilder();

            m_consoleConverter = new CharToLineConverter(text => {
                NewOutput(text);
            });

            m_warningConverter = new CharToLineConverter(text => {
                NewOutput(text, warningColor);
            });

            m_errorConverter = new CharToLineConverter(text => {
                NewOutput(text, errorColor);
            });

            Out   = new StandardStreamWriter((text) => WriteOutput(OutputType.Normal, text));
            Error = new StandardStreamWriter((text) => WriteOutput(OutputType.Error, text));

            // Hook ctrl-C and ctrl-break
            Console.CancelKeyPress += new ConsoleCancelEventHandler(OnCtrlBreakKeyPress);
        }