using System.Collections.Generic; namespace DCFApixels.DragonECS { public interface IConfig { int Count { get; } bool Has(string valueName); T Get(string valueName); bool TryGet(string valueName, out T value); IEnumerable> GetAllConfigs(); } public interface IConfigWriter { int Count { get; } void Set(string valueName, T value); bool Has(string valueName); T Get(string valueName); bool TryGet(string valueName, out T value); void Remove(string valueName); IEnumerable> GetAllConfigs(); } public static class ConfigExtensions { public static T GetOrDefault(this IConfig self, string valueName, T defaultValue) { if (self.TryGet(valueName, out T value)) { return value; } return defaultValue; } } }