flatten configuration file structure

This commit is contained in:
cuqmbr 2025-05-29 12:24:13 +03:00
parent 9ccd0bb68d
commit 41158b34c5
Signed by: cuqmbr
GPG Key ID: 0AA446880C766199
7 changed files with 69 additions and 77 deletions

View File

@ -2,7 +2,7 @@ namespace cuqmbr.TravelGuide.Application;
public sealed class ConfigurationOptions
{
public static string SectionName { get; } = "Application";
public static string SectionName { get; } = "";
public LocalizationConfigurationOptions Localization { get; set; } = new();

View File

@ -25,17 +25,14 @@ public static class Configuration
.AddCommandLine(args)
.Build();
services.AddOptions<PersistenceConfigurationOptions>().Bind(
configuration.GetSection(
PersistenceConfigurationOptions.SectionName));
services.AddOptions<PersistenceConfigurationOptions>()
.Bind(configuration);
services.AddOptions<ApplicationConfigurationOptions>().Bind(
configuration.GetSection(
ApplicationConfigurationOptions.SectionName));
services.AddOptions<ApplicationConfigurationOptions>()
.Bind(configuration);
services.AddOptions<InfrastructureConfigurationOptions>().Bind(
configuration.GetSection(
InfrastructureConfigurationOptions.SectionName));
services.AddOptions<InfrastructureConfigurationOptions>()
.Bind(configuration);
return services;
}

View File

@ -21,7 +21,10 @@ public static class Configuration
ExchangeApiCurrencyConverterService>()
.AddScoped<
cuqmbr.TravelGuide.Application.Common.Services.LiqPayPaymentService,
cuqmbr.TravelGuide.Infrastructure.Services.LiqPayPaymentService>();
cuqmbr.TravelGuide.Infrastructure.Services.LiqPayPaymentService>()
.AddScoped<
EmailSenderService,
MailKitEmailSenderService>();
return services;
}

View File

@ -1,15 +1,10 @@
{
"Application": {
"Logging": {
"Type": "SimpleConsole",
"LogLevel": "Information",
"TimestampFormat": "yyyy-MM-ddTHH:mm:ss.fffK",
"UseUtcTimestamp": true
},
"Datastore": {
"Type": "postgresql",
"ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000;Include Error Detail=true"
},
"Localization": {
"DefaultCultureName": "en-US",
"CacheDuration": "00:30:00"
@ -21,7 +16,10 @@
"AccessTokenValidity": "24:00:00",
"RefreshTokenValidity": "72:00:00"
},
"Infrastructure": {
"Datastore": {
"Type": "postgresql",
"ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000;Include Error Detail=true"
},
"PaymentProcessing": {
"CallbackAddressBase": "https://api.travel-guide.cuqmbr.xyz",
"ResultAddressBase": "https://travel-guide.cuqmbr.xyz",
@ -31,5 +29,3 @@
}
}
}
}
}

View File

@ -1,15 +1,10 @@
{
"Application": {
"Logging": {
"Type": "SimpleConsole",
"LogLevel": "Information",
"TimestampFormat": "yyyy-MM-ddTHH:mm:ss.fffK",
"UseUtcTimestamp": true
},
"Datastore": {
"Type": "postgresql",
"ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000;Include Error Detail=true"
},
"Localization": {
"DefaultCultureName": "en-US",
"CacheDuration": "00:30:00"
@ -21,7 +16,10 @@
"AccessTokenValidity": "24:00:00",
"RefreshTokenValidity": "72:00:00"
},
"Infrastructure": {
"Datastore": {
"Type": "postgresql",
"ConnectionString": "Host=127.0.0.1:5432;Database=travel_guide;Username=postgres;Password=0000;Include Error Detail=true"
},
"PaymentProcessing": {
"CallbackAddressBase": "https://api.travel-guide.cuqmbr.xyz",
"ResultAddressBase": "https://travel-guide.cuqmbr.xyz",
@ -31,5 +29,3 @@
}
}
}
}
}

View File

@ -2,9 +2,9 @@ namespace cuqmbr.TravelGuide.Infrastructure;
public sealed class ConfigurationOptions
{
public static string SectionName { get; } = "Application:Infrastructure";
public static string SectionName { get; } = "";
public PaymentProcessingConfigurationOptions PaymentProcessing { get; set; }
public PaymentProcessingConfigurationOptions PaymentProcessing { get; set; } = new();
}
public sealed class PaymentProcessingConfigurationOptions
@ -13,7 +13,7 @@ public sealed class PaymentProcessingConfigurationOptions
public string ResultAddressBase { get; set; }
public LiqPayConfigurationOptions LiqPay { get; set; }
public LiqPayConfigurationOptions LiqPay { get; set; } = new();
}
public sealed class LiqPayConfigurationOptions

View File

@ -2,7 +2,7 @@ namespace cuqmbr.TravelGuide.Persistence;
public sealed class ConfigurationOptions
{
public static string SectionName { get; } = "Application:Datastore";
public static string SectionName { get; } = "Datastore";
public string Type { get; set; } = "inmemory";