Import from internal git
This commit is contained in:
64
Generator/DataSource/Settings/ConfigManager.cs
Normal file
64
Generator/DataSource/Settings/ConfigManager.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using Core;
|
||||
using Core.Dto;
|
||||
using Core.Dto.Settings;
|
||||
using Core.Settings;
|
||||
using Generator.Mappers;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Generator.DataSource.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// This class is intended to encapsulate configurations objects
|
||||
/// </summary>
|
||||
public class ConfigManager
|
||||
{
|
||||
private readonly ArgumentsDto _args;
|
||||
|
||||
private readonly EnvironmentConfigDto _env;
|
||||
private readonly DefaultArgumentsConfigDto _defArgs;
|
||||
private readonly GeneralConfigDto _general;
|
||||
|
||||
public readonly DockerImagesConfigDto DockerImages;
|
||||
public readonly TemplatesConfigDto Templates;
|
||||
public readonly PublishConfigDto Publish;
|
||||
public readonly CredentialsConfigDto Credentials;
|
||||
public readonly DotnetConfigDto Dotnet;
|
||||
public readonly JavaConfigDto Java;
|
||||
public readonly JavascriptConfigDto Javascript;
|
||||
public readonly OpenApiConfigDto OpenApi;
|
||||
|
||||
public ConfigManager(
|
||||
ArgumentsDto args,
|
||||
IOptions<EnvironmentConfigDto> env,
|
||||
IOptions<DefaultArgumentsConfigDto> defArgs,
|
||||
IOptions<GeneralConfigDto> general,
|
||||
IOptions<PublishConfigDto> publish,
|
||||
IOptions<CredentialsConfigDto> creds,
|
||||
IOptions<DockerImagesConfigDto> images,
|
||||
IOptions<DotnetConfigDto> dotnet,
|
||||
IOptions<JavaConfigDto> java,
|
||||
IOptions<JavascriptConfigDto> javascript,
|
||||
IOptions<OpenApiConfigDto> openapi,
|
||||
IOptions<TemplatesConfigDto> templates)
|
||||
{
|
||||
_args = args;
|
||||
_env = env.Value;
|
||||
Publish = publish.Value;
|
||||
Credentials = creds.Value;
|
||||
_defArgs = defArgs.Value;
|
||||
_general = general.Value;
|
||||
|
||||
DockerImages = images.Value;
|
||||
Templates = templates.Value;
|
||||
Dotnet = dotnet.Value;
|
||||
Java = java.Value;
|
||||
Javascript = javascript.Value;
|
||||
OpenApi = openapi.Value;
|
||||
}
|
||||
|
||||
public BaseConfig GetBase() => _env.Map();
|
||||
public DefaultArgumentsConfig GetDefArgs() => _defArgs.Map(_args);
|
||||
public GeneralConfig GetGeneral() => _general.Map();
|
||||
public Location GetRoot(bool isLocal) => isLocal ? GetBase().LocalRoot : GetBase().DockerRoot;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user