DependencyInjection.cs 491 B

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