Пример #1
0
        public ProcessOutput GetConsoleOutput()
        {
            ProcessOutput output = StopConsoleRedirection();

            WriteConsole(ConsoleOut.ToString());
            Console.Error.WriteLine(ConsoleErr.ToString());
            StartConsoleRedirection();
            return(output);
        }
Пример #2
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);
        }
Пример #3
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);
        }