Finalizes ConfigurationBuilder with indexer
This commit is contained in:
parent
1f675498a2
commit
6839cd82e2
5 changed files with 43 additions and 11 deletions
|
|
@ -23,7 +23,7 @@ namespace Core.Configurations
|
|||
{
|
||||
provider.Build();
|
||||
}
|
||||
//TODO: we need to come up with merge strategy
|
||||
//TODO: we need to come up with merge strategy, right now the latest key-path dominates
|
||||
|
||||
return new ConfigurationRoot(ConfigurationProviders);
|
||||
}
|
||||
|
|
@ -33,6 +33,14 @@ namespace Core.Configurations
|
|||
{
|
||||
List<IConfigurationProvider> _providers = [];
|
||||
|
||||
/// <summary>
|
||||
/// Implements a string-based indexer for backwards compatibility with Microsoft.Extensions.Configuration.
|
||||
/// This implementation is marked as obsolete and should be replaced with type-safe alternatives.
|
||||
/// </summary>
|
||||
/// <param name="key">The configuration key to retrieve.</param>
|
||||
/// <returns>The configuration value for the specified key.</returns>
|
||||
/// <exception cref="NotSupportedException">Thrown when attempting to set a value, as this operation is not supported.</exception>
|
||||
[Obsolete("Use type-safe configuration methods instead")]
|
||||
public string this[string key]
|
||||
{
|
||||
get => GetConfiguration(_providers, key);
|
||||
|
|
@ -58,14 +66,10 @@ namespace Core.Configurations
|
|||
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class ConfigurationRoot : Configuration, IConfigurationRoot
|
||||
{
|
||||
List<IConfigurationProvider> IConfiguration.ConfigurationProviders { get; set; }
|
||||
|
||||
public ConfigurationRoot(List<IConfigurationProvider> configurationProviders)
|
||||
{
|
||||
((IConfiguration)this).ConfigurationProviders = configurationProviders;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue