You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/ZeroLevel/Services/Config/Implementation/ApplicationConfigReader.cs

40 lines
1.3 KiB

namespace ZeroLevel.Services.Config.Implementation
{
internal sealed class ApplicationConfigReader
: IConfigurationReader
{
private readonly AppWebConfigReader _reader;
internal ApplicationConfigReader() { _reader = new AppWebConfigReader(); }
internal ApplicationConfigReader(string configFilePath) { _reader = new AppWebConfigReader(configFilePath); }
public IConfiguration ReadConfiguration()
{
var result = Configuration.Create();
foreach (var pair in _reader.ReadAppSettings())
{
result.Append(pair.Item1, pair.Item2);
}
return result;
}
public IConfigurationSet ReadConfigurationSet()
{
var result = Configuration.CreateSet();
foreach (var pair in _reader.ReadAppSettings())
{
result.Default.Append(pair.Item1, pair.Item2);
}
foreach (var section in _reader.GetSections())
{
var sectionConfig = result.CreateSection(section);
foreach (var pair in _reader.ReadSection(section))
{
sectionConfig.Append(pair.Item1, pair.Item2);
}
}
return result;
}
}
}

Powered by TurnKey Linux.