Пример #1
0
 public DebugConsole()
 {
     stringBuilder            = new();
     textWriter               = new(stringBuilder);
     multiplexer              = new ConsoleOutputMultiplexer(textWriter);
     multiplexer.WrittenText += () => WrittenText?.Invoke();
 }
Пример #2
0
 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();
 }
Пример #3
0
 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();
 }
Пример #4
0
 public override void Write(System.ReadOnlySpan <char> buffer)
 {
     foreach (System.IO.TextWriter thisWriter in MWriters)
     {
         thisWriter.Write(buffer);
     }
     WrittenText?.Invoke();
 }
Пример #5
0
 public override void Write(char[] buffer, int index, int count)
 {
     foreach (System.IO.TextWriter thisWriter in MWriters)
     {
         thisWriter.Write(buffer, index, count);
     }
     WrittenText?.Invoke();
 }
Пример #6
0
        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);
            }
        }