Example #1
0
 public void FlushConsoleOutput()
 {
     Console.Out.Flush();
     Console.Error.Flush();
     ConsoleOut.Flush();
     ConsoleErr.Flush();
 }
Example #2
0
        public ProcessOutput GetConsoleOutput()
        {
            ProcessOutput output = StopConsoleRedirection();

            WriteConsole(ConsoleOut.ToString());
            Console.Error.WriteLine(ConsoleErr.ToString());
            StartConsoleRedirection();
            return(output);
        }
Example #3
0
        public ProcessOutput StopConsoleRedirection()
        {
            FlushConsoleOutput();
            ProcessOutput output = new ProcessOutput
            {
                StandardError  = ConsoleErr.ToString(),
                StandardOutput = ConsoleOut.ToString()
            };

            Console.SetOut(Console.Out);
            Console.SetError(Console.Error);
            return(output);
        }
Example #4
0
        public ProcessOutput StopConsoleRedirection()
        {
            Log.Info("stopping redirection");
            // give time for logging to finish
            Thread.Sleep(1000);
            Log.Close();
            FlushConsoleOutput();
            ProcessOutput output = new ProcessOutput
            {
                StandardError  = ConsoleErr.ToString(),
                StandardOutput = ConsoleOut.ToString()
            };

            ConsoleErr = new StringWriter();
            ConsoleOut = new StringWriter();

            Console.SetOut(Console.Out);
            Console.SetError(Console.Error);

            consoleOutBuilder.Append(output.StandardOutput);
            consoleErrBuilder.Append(output.StandardError);

            return(output);
        }