DependencyInjection.cs 541 B

1234567891011121314151617181920
  1. using Application.Behaviors;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using System.Reflection;
  4. namespace Application
  5. {
  6. public static class DependencyInjection
  7. {
  8. public static IServiceCollection AddApplication(this IServiceCollection services)
  9. {
  10. services.AddMediatR(cfg =>
  11. {
  12. cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
  13. cfg.AddOpenBehavior(typeof(LoggingBehavior<,>));
  14. });
  15. return services;
  16. }
  17. }
  18. }