25 lines
908 B
C#
25 lines
908 B
C#
using CleanArchitecture.Application.Behaviours;
|
|
using FluentValidation;
|
|
using MediatR;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System.Reflection;
|
|
|
|
namespace CleanArchitecture.Application
|
|
{
|
|
public static class ApplicationServiceRegistration
|
|
{
|
|
public static IServiceCollection AddApplicationServices(this IServiceCollection services)
|
|
{
|
|
services.AddAutoMapper(Assembly.GetExecutingAssembly());
|
|
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
|
|
|
|
services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()));
|
|
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(UnhandledExceptionBehaviour<,>));
|
|
|
|
services.AddTransient(typeof(IPipelineBehavior<,>), typeof(ValidationBehaviour<,>));
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|