diff --git a/Source/Shared/Features/EFCore/Configuration/EFCoreConfiguration.cs b/Source/Shared/Features/EFCore/Configuration/EFCoreConfiguration.cs index 977f124f..bdfbd7a1 100644 --- a/Source/Shared/Features/EFCore/Configuration/EFCoreConfiguration.cs +++ b/Source/Shared/Features/EFCore/Configuration/EFCoreConfiguration.cs @@ -1,6 +1,8 @@ -namespace Shared.Features.EFCore.Configuration +using Shared.Features.Modules.Configuration; + +namespace Shared.Features.EFCore.Configuration { - public class EFCoreConfiguration + public class EFCoreConfiguration : IModuleConfiguration { public string SQLServerConnectionString_Dev { get; set; } public string SQLServerConnectionString_Prod { get; set; } diff --git a/Source/Shared/Features/EFCore/Registrator.cs b/Source/Shared/Features/EFCore/Registrator.cs index 098460fb..5394ff52 100644 --- a/Source/Shared/Features/EFCore/Registrator.cs +++ b/Source/Shared/Features/EFCore/Registrator.cs @@ -1,8 +1,8 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; using Shared.Features.EFCore.Configuration; +using Shared.Features.Modules.Configuration; namespace Shared.Features.EFCore { @@ -10,9 +10,8 @@ public static class Registrator { public static IServiceCollection AddEFCore(this IServiceCollection services, IConfiguration configuration) { - services.Configure(configuration.GetSection(nameof(EFCoreConfiguration))); - services.AddScoped(sp => sp.GetRequiredService>().Value); - services.AddSingleton, EFCoreConfigurationValidator>(); + services.RegisterModuleConfiguration(configuration); + services.AddScoped(); return services; } diff --git a/Source/Shared/Features/Modules/Configuration/Registrator.cs b/Source/Shared/Features/Modules/Configuration/Registrator.cs index 3ec1dd5c..f039d65b 100644 --- a/Source/Shared/Features/Modules/Configuration/Registrator.cs +++ b/Source/Shared/Features/Modules/Configuration/Registrator.cs @@ -12,7 +12,7 @@ public static class Registrator services.AddScoped(sp => { TModuleConfiguration sc = new TModuleConfiguration(); - sp.GetRequiredService().GetSection(nameof(TModuleConfiguration)).Bind(sc); + sp.GetRequiredService().GetSection(typeof(TModuleConfiguration).Name).Bind(sc); return sc; }); @@ -25,7 +25,7 @@ public static class Registrator services.AddScoped(sp => { TModuleConfiguration sc = new TModuleConfiguration(); - sp.GetRequiredService().GetSection(nameof(TModuleConfiguration)).Bind(sc); + sp.GetRequiredService().GetSection(typeof(TModuleConfiguration).Name).Bind(sc); return sc; });