Implement configuration system with embedded TOML resources for agent and provider definitions, custom IConfigurationSource/Provider for agent and provider options, and DI extension methods. Includes config models for agents, providers, sessions, and Telegram integration.
20 lines
634 B
C#
20 lines
634 B
C#
using System.Reflection;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace Luna.Configuration.Services.Agents;
|
|
|
|
internal class AgentOptionsConfigurationProvider(IEnumerable<AgentOptions> agentOptions) : ConfigurationProvider
|
|
{
|
|
public override void Load()
|
|
{
|
|
foreach (var options in agentOptions)
|
|
{
|
|
var keyPrefix = $"Agents:{options.Name}";
|
|
|
|
foreach (var property in options.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
|
|
{
|
|
Data[$"{keyPrefix}:{property.Name}"] = property.GetValue(options)?.ToString();
|
|
}
|
|
}
|
|
}
|
|
} |