Ejemplo n.º 1
0
        public static void ClosePluginInstance(ProfilePluginConfiguration config, 
            IJinxBotPlugin pluginInstance)
        {
            lock (m_lock)
            {
                SavePluginInstanceConfig(config, pluginInstance);

                IMultiClientPlugin mcp = pluginInstance as IMultiClientPlugin;
                if (mcp != null)
                {
                    int count = m_instanceCounter[mcp];
                    if (count == 1)
                    {
                        // this is the last instance, so shut it down completely
                        m_instanceCounter.Remove(mcp);
                        mcp.DestroyPluginWindows(MainWindow);
                        string name = m_instancesToNames[mcp];
                        m_instancesToNames.Remove(mcp);
                        m_activeMultiClientPlugins.Remove(name);
                    }
                    else
                    {
                        m_instanceCounter[mcp] = count - 1;
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private static void SavePluginInstanceConfig(ProfilePluginConfiguration config, IJinxBotPlugin pluginInstance)
 {
     Dictionary<string, string> settings = config.Settings.ToDictionary(s => s.Name, s => s.Value);
     pluginInstance.Shutdown(settings);
     List<ProfilePluginSettingConfiguration> settingsToSave = new List<ProfilePluginSettingConfiguration>();
     foreach (string key in settings.Keys)
     {
         settingsToSave.Add(new ProfilePluginSettingConfiguration { Name = key, Value = settings[key] });
     }
     config.Settings = settingsToSave.ToArray();
 }