58 lines
1.6 KiB
C#
58 lines
1.6 KiB
C#
using FluentValidation;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using PARR.Core.Common.Implementations;
|
|
using PARR.Core.Common.Interfaces;
|
|
|
|
namespace PARR.Core
|
|
{
|
|
public static class DependencyInjection
|
|
{
|
|
|
|
/// <summary>
|
|
/// Регистрация Core (BLL) сервисов
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
/// <param name="configuration"></param>
|
|
/// <returns></returns>
|
|
public static IServiceCollection AddCoreServices(this IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
// Регим профили AutoMapper
|
|
services.AddBllMapping();
|
|
|
|
// Регим все валидаторы в Core
|
|
services.AddValidatorsFromAssembly(typeof(DependencyInjection).Assembly, includeInternalTypes: true);
|
|
|
|
// Регистрируем сревисы Core
|
|
|
|
#region Common
|
|
|
|
services.AddTransient<ITransformService, TransformService>();
|
|
|
|
#endregion
|
|
|
|
#region Services
|
|
|
|
//services.AddScoped<IUserService, UserService>();
|
|
|
|
#endregion
|
|
|
|
return services;
|
|
}
|
|
|
|
|
|
private static IServiceCollection AddBllMapping(this IServiceCollection services)
|
|
{
|
|
// AutoMapper
|
|
services.AddAutoMapper(cfg =>
|
|
{
|
|
// регим все в Core
|
|
cfg.AddMaps(typeof(DependencyInjection).Assembly);
|
|
});
|
|
|
|
return services;
|
|
}
|
|
|
|
}
|
|
}
|