public DebugConsole() { stringBuilder = new(); textWriter = new(stringBuilder); multiplexer = new ConsoleOutputMultiplexer(textWriter); multiplexer.WrittenText += () => WrittenText?.Invoke(); }
public override async System.Threading.Tasks.Task WriteAsync(System.ReadOnlyMemory <char> buffer, System.Threading.CancellationToken cancellationToken = default) { foreach (System.IO.TextWriter thisWriter in MWriters) { await thisWriter.WriteAsync(buffer, cancellationToken); } WrittenText?.Invoke(); }
public override async System.Threading.Tasks.Task WriteAsync(char[] buffer, int index, int count) { foreach (System.IO.TextWriter thisWriter in MWriters) { await thisWriter.WriteAsync(buffer, index, count); } WrittenText?.Invoke(); }
public override void Write(System.ReadOnlySpan <char> buffer) { foreach (System.IO.TextWriter thisWriter in MWriters) { thisWriter.Write(buffer); } WrittenText?.Invoke(); }
public override void Write(char[] buffer, int index, int count) { foreach (System.IO.TextWriter thisWriter in MWriters) { thisWriter.Write(buffer, index, count); } WrittenText?.Invoke(); }
public ConsoleOutputMultiplexer(StringWriter stringWriter) { oldOut = System.Console.Out; try { multiPlexer = new MultiTextWriter(oldOut.Encoding, oldOut, stringWriter); multiPlexer.WrittenText += () => WrittenText?.Invoke(); System.Console.SetOut(multiPlexer); } catch (System.Exception e) { System.Console.WriteLine("Cannot open Redirect.txt for writing"); System.Console.WriteLine(e.Message); } }