using MareSynchronosShared.Utils; using Microsoft.Extensions.Options; using System.Text; namespace MareSynchronosShared.Services; public class MareConfigurationServiceServer : IConfigurationService where T : class, IMareConfiguration { private readonly T _config; public bool IsMain => true; public MareConfigurationServiceServer(IOptions config) { _config = config.Value; } public T1 GetValueOrDefault(string key, T1 defaultValue) { return _config.GetValueOrDefault(key, defaultValue); } public T1 GetValue(string key) { return _config.GetValue(key); } public override string ToString() { var props = _config.GetType().GetProperties(); StringBuilder sb = new(); foreach (var prop in props) { sb.AppendLine($"{prop.Name} (IsRemote: {prop.GetCustomAttributes(typeof(RemoteConfigurationAttribute), true).Any()}) => {prop.GetValue(_config)}"); } return sb.ToString(); } }