using System; using System.Collections.Generic; namespace SharedLibrary.Helpers { public class ConfigurationManager { Dictionary> ConfigurationSet; Type PluginType; public ConfigurationManager(Type PluginType) { ConfigurationSet = new Dictionary>(); this.PluginType = PluginType; } public void AddConfiguration(Server S) { try { var Config = Interfaces.Serialize>.Read($"config/{PluginType.ToString()}_{S.ToString()}.cfg"); lock (ConfigurationSet) { ConfigurationSet.Add(S.ToString(), Config); } } catch (Exceptions.SerializeException) { ConfigurationSet.Add(S.ToString(), new Dictionary()); } } public void AddProperty(Server S, KeyValuePair Property) { ConfigurationSet[S.ToString()].Add(Property.Key, Property.Value); Interfaces.Serialize>.Write($"config/{PluginType.ToString()}_{S.ToString()}.cfg", ConfigurationSet[S.ToString()]); } public void UpdateProperty(Server S, KeyValuePair Property) { ConfigurationSet[S.ToString()][Property.Key] = Property.Value; Interfaces.Serialize>.Write($"config/{PluginType.ToString()}_{S.ToString()}.cfg", ConfigurationSet[S.ToString()]); } public IDictionary GetConfiguration(Server S) { return ConfigurationSet[S.ToString()]; } } }