Closed 274188A closed 1 year ago
Moving off depreciated MediatR.Courier.DependencyInjection
What is the alternative to what was MediatRCourier on MediatR.Courier.DependencyInjection" Version="5.0.0
MediatRCourier
MediatR.Courier.DependencyInjection" Version="5.0.0
Sample code:
{ public static IServiceCollection AddNotifications(this IServiceCollection services) { // Add mediator processing of notifications var assemblies = AppDomain.CurrentDomain.GetAssemblies(); services .AddMediatR(assemblies) .AddCourier(assemblies) .AddTransient<INotificationPublisher, NotificationPublisher>(); // Register handlers for all INotificationMessages foreach (var eventType in assemblies .SelectMany(a => a.GetTypes()) .Where(t => t.GetInterfaces().Any(i => i == typeof(INotificationMessage)))) { services.AddSingleton( typeof(INotificationHandler<>).MakeGenericType( typeof(NotificationWrapper<>).MakeGenericType(eventType)), serviceProvider => serviceProvider.GetRequiredService(typeof(MediatRCourier))); } return services; } }
TIA!
Moving off depreciated MediatR.Courier.DependencyInjection
What is the alternative to what was
MediatRCourier
onMediatR.Courier.DependencyInjection" Version="5.0.0
Sample code:
TIA!