public static void FromFile(string file, IDictionary <string, bool> states) { if (File.Exists(file)) { using (FileStream stream = File.OpenRead(file)) { PluginStates s = configSerializer.Deserialize(stream) as PluginStates; foreach (PluginConfigItem item in s.Plugins) { states[item.PluginTypeString] = item.Disabled; } } } }
public static void ToFile(IDictionary <string, bool> states, string file) { PluginStates s = new PluginStates(); foreach (KeyValuePair <string, bool> kvp in states) { s.Plugins.Add(new PluginConfigItem() { PluginTypeString = kvp.Key, Disabled = kvp.Value }); } s.Plugins.Sort(); using (FileStream stream = File.Create(file)) configSerializer.Serialize(stream, s); }
public static void LoadPluginStates() { bool changed = false; lock (_statesLock) { _states.Clear(); PluginStates.FromFile(statesFile, _states); foreach (var item in _catalog.Parts) { string pluginName = item.ToString(); if (!_states.ContainsKey(pluginName)) { Utils.Log(String.Format(" - Adding plugin [{0}]", pluginName)); changed = true; _states[pluginName] = true; // Disabled when added } } } if (changed) { SavePluginStates(); } }
public static void SavePluginStates() { PluginStates.ToFile(_states, statesFile); }