| | 1 | | using Microsoft.Extensions.Configuration; |
| | 2 | | using Microsoft.Extensions.DependencyInjection; |
| | 3 | | using MRA.Infrastructure.Settings; |
| | 4 | | using MRA.Infrastructure.Settings.Options; |
| | 5 | | using MRA.Infrastructure.Settings.Sections; |
| | 6 | |
|
| | 7 | | namespace MRA.DependencyInjection.Startup; |
| | 8 | |
|
| | 9 | | public static class ConfigurationStartup |
| | 10 | | { |
| | 11 | | public static void AddCustomConfiguration(this IServiceCollection services) |
| | 12 | | { |
| 1 | 13 | | services.AddSingleton(sp => |
| 1 | 14 | | { |
| 1 | 15 | | return sp.GetRequiredService<IConfiguration>().GetMRAConfiguration(); |
| 1 | 16 | | }); |
| 1 | 17 | | } |
| | 18 | |
|
| | 19 | | public static AppSettings GetMRAConfiguration(this IConfiguration config) |
| | 20 | | { |
| 1 | 21 | | var appConfig = new AppSettings |
| 1 | 22 | | { |
| 1 | 23 | | AzureStorage = config.GetSection("AzureStorage").Get<AzureStorageSettings>(), |
| 1 | 24 | | AzureKeyVault = config.GetSection("AzureKeyVault").Get<AzureKeyVaultSettings>(), |
| 1 | 25 | | Administrator = config.GetSection("Administrator").Get<AdministratorSettings>(), |
| 1 | 26 | | Jwt = config.GetSection("Jwt").Get<JwtSettings>(), |
| 1 | 27 | | Cache = config.GetSection("Cache").Get<CacheSettings>(), |
| 1 | 28 | | Firebase = config.GetSection("Firebase").Get<FirebaseSettings>(), |
| 1 | 29 | | MRALogger = config.GetSection("MRALogger").Get<MRALoggerSettings>(), |
| 1 | 30 | | EPPlus = config.GetSection("EPPlus").Get<EPPlusSettings>(), |
| 1 | 31 | | AzureCosmosDb = config.GetSection("AzureCosmosDb").Get<AzureCosmosSettings>(), |
| 1 | 32 | | Database = config.GetSection("Database").Get<DatabaseSettings>(), |
| 1 | 33 | | RemoteConfig = config.GetSection("RemoteConfig").Get<RemoteConfigSettings>(), |
| 1 | 34 | | Commands = config.GetSection("Commands").Get<CommandsSettings>() |
| 1 | 35 | | }; |
| | 36 | |
|
| 1 | 37 | | return appConfig; |
| | 38 | | } |
| | 39 | | } |