This decorator is going to support the logging of inputs and outputs of every method from a class, thus, I define the following interface and its implementation:
public interface IFoo
{
string Bar(string text);
}
public class Foo : IFoo
{
public string Bar(string text)
{
return text;
}
}
Given the above interface, I define the following decorator
public class Foo_IO_Decorator : IFoo
{
private readonly IFoo decorated;
public Foo_IO_Decorator(IFoo decorated)
{
this.decorated = decorated;
}
public string Bar(string text)
{
// TODO: provide a mechanics to log the input
string result = decorated.Bar(text);
// TODO: provide a mechanics to log the output
return result;
}
}
Note: For methods which don't accept any parameters or return void, input and respectively output logging will be NOT be performed.
This decorator is going to support the logging of inputs and outputs of every method from a class, thus, I define the following interface and its implementation:
Given the above interface, I define the following decorator
Note: For methods which don't accept any parameters or return void, input and respectively output logging will be NOT be performed.