design-patterns/Decorator/DecoratedComponent.cs

16 lines
441 B
C#
Raw Permalink Normal View History

2023-09-04 08:55:08 +00:00
public class DecoratedComponent : IComponent
{
private readonly IComponent _component;
public DecoratedComponent(IComponent component)
{
_component = component ?? throw new ArgumentNullException(nameof(component));
}
public void DoSomething()
{
Console.WriteLine("I can add functionality before");
_component.DoSomething();
Console.WriteLine("I can add functionality after");
}
}