示例#1
0
 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;
             }
         }
     }
 }
示例#2
0
        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);
        }
示例#3
0
        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();
            }
        }
示例#4
0
 public static void SavePluginStates()
 {
     PluginStates.ToFile(_states, statesFile);
 }