2025-01-30 18:03:24 +01:00
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.Primitives;
|
|
|
|
|
using System.Data;
|
|
|
|
|
|
|
|
|
|
namespace Core.Configurations.SmartConfiguration;
|
2025-01-31 22:08:54 +01:00
|
|
|
public class JsonConfiguration : Microsoft.Extensions.Configuration.IConfiguration
|
2025-01-30 18:03:24 +01:00
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 22:08:54 +01:00
|
|
|
public Microsoft.Extensions.Configuration.IConfigurationSection GetSection(string key) => null;
|
|
|
|
|
//new JsonConfigurationSection(_data, key);
|
2025-01-30 18:03:24 +01:00
|
|
|
|
|
|
|
|
public IEnumerable<IConfigurationSection> GetChildren() =>
|
|
|
|
|
_data.Properties().Select(p => new JsonConfigurationSection(_data, p.Name));
|
|
|
|
|
|
|
|
|
|
public IChangeToken GetReloadToken() => throw new NotImplementedException();
|
2025-01-31 22:08:54 +01:00
|
|
|
|
|
|
|
|
IEnumerable<Microsoft.Extensions.Configuration.IConfigurationSection> IConfiguration.GetChildren()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
2025-01-30 18:03:24 +01:00
|
|
|
}
|