using Microsoft.Extensions.DependencyInjection;
using System.Collections.Generic;
using System.Threading.Tasks;
public delegate Task OnBeforeResponseAsync(string value);
public static async Task Main()
var serviceProvider = new ServiceCollection()
var handlers = serviceProvider.GetServices<OnBeforeResponseAsync>();
foreach (var handleAsync in handlers)
await handleAsync("test");