using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
public class LoggingDecorator : IDecorator
public async Task OnInvoke(Call call)
Console.WriteLine("Will do some work!");
Console.WriteLine("Work is finished!");
public class Worker : IWorker
[Decorate(typeof(LoggingDecorator))]
Console.WriteLine("Working...");
var serviceProvider = new ServiceCollection()
.AddSingleton<IUnityContainer,UnityContainer>()
.AddTransient<LoggingDecorator>()
.AddSingleton<IWorker, Worker>()
var worker = serviceProvider.GetRequiredService<IWorker>();