WIP on Config Handling
This commit is contained in:
parent
4dc03f2cbf
commit
8e6492e979
17 changed files with 314 additions and 288 deletions
29
Core/Configurations/SmartConfiguration/JsonConfiguration.cs
Normal file
29
Core/Configurations/SmartConfiguration/JsonConfiguration.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
using System.Data;
|
||||
|
||||
namespace Core.Configurations.SmartConfiguration;
|
||||
public class JsonConfiguration : IConfiguration
|
||||
{
|
||||
private readonly JObject _data;
|
||||
|
||||
public JsonConfiguration(JObject data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public string this[string key]
|
||||
{
|
||||
get => _data.SelectToken(key.Replace(":", "."))?.ToString();
|
||||
set => throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IConfigurationSection GetSection(string key) =>
|
||||
new JsonConfigurationSection(_data, key);
|
||||
|
||||
public IEnumerable<IConfigurationSection> GetChildren() =>
|
||||
_data.Properties().Select(p => new JsonConfigurationSection(_data, p.Name));
|
||||
|
||||
public IChangeToken GetReloadToken() => throw new NotImplementedException();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue