2021-12-19 18:44:03 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
|
|
|
|
namespace Selector.Events
|
|
|
|
|
{
|
|
|
|
|
public static class ServiceExtensions
|
|
|
|
|
{
|
2022-02-18 00:08:42 +00:00
|
|
|
|
public static IServiceCollection AddEvents(this IServiceCollection services)
|
2021-12-19 18:44:03 +00:00
|
|
|
|
{
|
|
|
|
|
services.AddEventBus();
|
|
|
|
|
services.AddEventMappingAgent();
|
2021-12-20 23:04:53 +00:00
|
|
|
|
|
|
|
|
|
services.AddTransient<IUserEventFirerFactory, UserEventFirerFactory>();
|
|
|
|
|
services.AddTransient<UserEventFirerFactory>();
|
2022-02-18 00:08:42 +00:00
|
|
|
|
|
|
|
|
|
return services;
|
2021-12-19 18:44:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-18 00:08:42 +00:00
|
|
|
|
public static IServiceCollection AddEventBus(this IServiceCollection services)
|
2021-12-19 18:44:03 +00:00
|
|
|
|
{
|
|
|
|
|
services.AddSingleton<UserEventBus>();
|
|
|
|
|
services.AddSingleton<IEventBus, UserEventBus>(sp => sp.GetRequiredService<UserEventBus>());
|
2022-02-18 00:08:42 +00:00
|
|
|
|
|
|
|
|
|
return services;
|
2021-12-19 18:44:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-02-18 00:08:42 +00:00
|
|
|
|
public static IServiceCollection AddEventMappingAgent(this IServiceCollection services)
|
2021-12-19 18:44:03 +00:00
|
|
|
|
{
|
|
|
|
|
services.AddHostedService<EventMappingService>();
|
2022-02-18 00:08:42 +00:00
|
|
|
|
|
|
|
|
|
return services;
|
2021-12-19 18:44:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|