feat: add DI
This commit is contained in:
parent
386272d493
commit
cfbd847d9a
19
Application/DependencyInjection.cs
Normal file
19
Application/DependencyInjection.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user