27 lines
647 B
C#
27 lines
647 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DotnetStreams
|
|
{
|
|
public class ProcessedConsoleOutputTarget : ConsoleOutputTarget
|
|
{
|
|
protected Func<string, string> processorFunc;
|
|
public ProcessedConsoleOutputTarget(Func<string, string> processorFunc) : base()
|
|
{
|
|
if (processorFunc != null)
|
|
this.processorFunc = processorFunc;
|
|
else
|
|
this.processorFunc = line => line;
|
|
}
|
|
|
|
public override void Output(string line)
|
|
{
|
|
string output = processorFunc?.Invoke(line) ?? string.Empty;
|
|
Console.WriteLine(output);
|
|
}
|
|
}
|
|
}
|