-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathErrorWriter.cs
More file actions
33 lines (29 loc) · 738 Bytes
/
Copy pathErrorWriter.cs
File metadata and controls
33 lines (29 loc) · 738 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.IO;
using System.Text;
namespace AutoAddScriptsToJson
{
public class ConsoleErrorWriterDecorator : TextWriter
{
protected readonly TextWriter OriginalTextWriter;
public ConsoleErrorWriterDecorator(TextWriter consoleTextWriter)
{
OriginalTextWriter = consoleTextWriter;
}
public override void WriteLine(string value)
{
ConsoleColor originalColor = Console.ForegroundColor;
if (originalColor == ConsoleColor.Red)
{
OriginalTextWriter.WriteLine(value);
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
OriginalTextWriter.WriteLine(value);
Console.ForegroundColor = originalColor;
}
}
public override Encoding Encoding => Encoding.Default;
}
}