Import from internal git
This commit is contained in:
46
Generator/DataSource/JsonLoader.cs
Normal file
46
Generator/DataSource/JsonLoader.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Core.Dto.Settings;
|
||||
using Core.Interfaces;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Generator.DataSource;
|
||||
|
||||
/// <summary>
|
||||
/// Provides some methods to load json objects from a json data source
|
||||
/// </summary>
|
||||
public class JsonLoader : IDataSourceLoader
|
||||
{
|
||||
private readonly IServiceCollection _services;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
|
||||
public JsonLoader(IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
_services = services;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load data that can be found in appsettings.json
|
||||
/// </summary>
|
||||
public void LoadAppsettings()
|
||||
{
|
||||
_services.AddOptions<EnvironmentConfigDto>().Bind(_configuration.GetSection("Environment"));
|
||||
_services.AddOptions<DefaultArgumentsConfigDto>().Bind(_configuration.GetSection("DefaultArguments"));
|
||||
_services.AddOptions<GeneralConfigDto>().Bind(_configuration.GetSection("General"));
|
||||
|
||||
_services.AddOptions<PublishConfigDto>().Bind(_configuration.GetSection("Publish"));
|
||||
_services.AddOptions<CredentialsConfigDto>().Bind(_configuration.GetSection("Credentials"));
|
||||
|
||||
_services.AddOptions<DockerImagesConfigDto>().Bind(_configuration.GetSection("DockerImages"));
|
||||
|
||||
_services.AddOptions<JavaConfigDto>().Bind(_configuration.GetSection("Java"));
|
||||
_services.AddOptions<DotnetConfigDto>().Bind(_configuration.GetSection("Dotnet"));
|
||||
_services.AddOptions<JavascriptConfigDto>().Bind(_configuration.GetSection("Javascript"));
|
||||
_services.AddOptions<OpenApiConfigDto>().Bind(_configuration.GetSection("OpenApi"));
|
||||
|
||||
_services.AddOptions<TemplatesConfigDto>().Bind(_configuration.GetSection("Templates"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user