public ProcessOutput GetConsoleOutput() { ProcessOutput output = StopConsoleRedirection(); WriteConsole(ConsoleOut.ToString()); Console.Error.WriteLine(ConsoleErr.ToString()); StartConsoleRedirection(); return(output); }
public ProcessOutput StopConsoleRedirection() { FlushConsoleOutput(); ProcessOutput output = new ProcessOutput { StandardError = ConsoleErr.ToString(), StandardOutput = ConsoleOut.ToString() }; Console.SetOut(Console.Out); Console.SetError(Console.Error); return(output); }
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); }