From cfbd847d9abb773661ea9618614916d5b9f675ac Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Mon, 8 Jan 2024 15:04:34 +0300 Subject: [PATCH] feat: add DI --- Application/DependencyInjection.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Application/DependencyInjection.cs diff --git a/Application/DependencyInjection.cs b/Application/DependencyInjection.cs new file mode 100644 index 0000000..2686e15 --- /dev/null +++ b/Application/DependencyInjection.cs @@ -0,0 +1,19 @@ +using MediatR; +using FluentValidation; +using Microsoft.Extensions.DependencyInjection; +using System.Reflection; +using Mirea.Api.DataAccess.Application.Common.Behaviors; + +namespace Mirea.Api.DataAccess.Application; + +public static class DependencyInjection +{ + public static IServiceCollection AddApplication(this IServiceCollection services) + { + services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly())); + services.AddValidatorsFromAssemblies(new[] { Assembly.GetExecutingAssembly() }); + services.AddTransient(typeof(IPipelineBehavior<,>), + typeof(ValidationBehavior<,>)); + return services; + } +} \ No newline at end of file