using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using PARR.DAL.Configurations.DbSettings; using PARR.DAL.Context; using PARR.DAL.Contracts; using PARR.DAL.Services.Implementation; using PARR.DAL.Services.Implementations; using PARR.DAL.Services.Implementations.AIHIT; using PARR.DAL.Services.Implementations.V1; using PARR.DAL.Services.Interfaces; using PARR.DAL.Services.Interfaces.AIHIT; using PARR.DAL.Services.Interfaces.V1; namespace PARR.DAL { public static class ParrDalInstaller { /// /// Устанавливает Dal сервисы (1) /// /// /// public static void InstallDalServices(this IServiceCollection services, IConfiguration configuration) { //.EnableSensitiveDataLogging() - вкл подробное логирование при применении миграций, на проде выключить services.AddDbContext(opt => opt .EnableSensitiveDataLogging() .UseNpgsql(configuration.GetConnectionString("DefaultConnection")) ); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); } /// /// Добавляет конфигурацию Dal (2) /// /// /// /// public static IConfigurationBuilder AddDalConfigurations(this IConfigurationBuilder builder, IServiceCollection services) { builder.Add(new DBConfigurationSource(services)); return builder; } /// /// Добавляет конфигурацию в сервисы (3) /// /// /// public static void AddDallSettings(this IServiceCollection services, IConfiguration configuration) { //SettingsFromDb configuration var settingsFromDb = new SettingsFromDb(); configuration.GetSection(nameof(SettingsFromDb)).Bind(settingsFromDb); services.AddSingleton(settingsFromDb); } } }