A utility library that adds an AddDecorator()
extension method to IServiceCollection
to make using the decorator pattern in .NET a breeze!
- Install
DotJoshJohnson.Decorators
via NuGet. - Add your base service implementation first, then any decorators.
using Microsoft.Extensions.DependencyInjection;
// ... //
services
.AddTransient<IMyService, MyService>()
.AddDecorator<IMyService, MyFirstDecorator>()
.AddDecorator<IMyService, MySecondDecorator>();
// ... //
var myDecoratedService = serviceProvider.GetRequiredService<IMyService>();
Party Balloons icon by Icons8