コード例 #1
0
        public void UnloadPlugin(IGUIPlugin plugin)
        {
            if (m_ActivePlugins.Contains(plugin))
            {
                DeactivatePlugin(plugin);
            }

            if (m_DormantPlugins.Contains(plugin))
            {
                m_DormantPlugins.Remove(plugin);
            }
        }
コード例 #2
0
ファイル: PluginController.cs プロジェクト: zakipatel/CKAN
        public void UnloadPlugin(IGUIPlugin plugin)
        {
            if (m_ActivePlugins.Contains(plugin))
            {
                log.Debug("Deactivate " + plugin.GetName());
                DeactivatePlugin(plugin);
            }

            if (m_DormantPlugins.Contains(plugin))
            {
                m_DormantPlugins.Remove(plugin);
            }
        }
コード例 #3
0
        public void DeactivatePlugin(IGUIPlugin plugin)
        {
            if (m_ActivePlugins.Contains(plugin))
            {
                try
                {
                    plugin.Deinitialize();
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Failed to deactivate plugin \"{0} - {1}\" - {2}", plugin.GetName(), plugin.GetVersion(), ex.Message);
                    return;
                }

                m_DormantPlugins.Add(plugin);
                m_ActivePlugins.Remove(plugin);
                log.InfoFormat("Deactivated plugin \"{0} - {1}\"", plugin.GetName(), plugin.GetVersion());
            }
        }
コード例 #4
0
ファイル: PluginController.cs プロジェクト: zakipatel/CKAN
        private void LoadAssembly(string dll)
        {
            Assembly assembly;

            try
            {
                assembly = Assembly.UnsafeLoadFrom(dll);
            }
            catch (Exception ex)
            {
                log.WarnFormat("Failed to load assembly \"{0}\" - {1}", dll, ex.Message);
                return;
            }

            log.InfoFormat("Loaded assembly - \"{0}\"", dll);

            try
            {
                var typeName = Path.GetFileNameWithoutExtension(dll);
                typeName = String.Format("{0}.{1}", typeName, typeName);

                Type       type           = assembly.GetType(typeName);
                IGUIPlugin pluginInstance = (IGUIPlugin)Activator.CreateInstance(type);

                foreach (var loadedPlugin in m_ActivePlugins)
                {
                    if (loadedPlugin.GetName() == pluginInstance.GetName())
                    {
                        if (loadedPlugin.GetVersion().IsLessThan(pluginInstance.GetVersion()))
                        {
                            DeactivatePlugin(loadedPlugin);
                            m_DormantPlugins.Remove(loadedPlugin);
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                foreach (var loadedPlugin in m_DormantPlugins)
                {
                    if (loadedPlugin.GetName() == pluginInstance.GetName())
                    {
                        if (loadedPlugin.GetVersion().IsLessThan(pluginInstance.GetVersion()))
                        {
                            m_DormantPlugins.Remove(loadedPlugin);
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                m_DormantPlugins.Add(pluginInstance);
                log.WarnFormat("Successfully instantiated type \"{0}\" from {1}.dll", assembly.FullName, assembly.FullName);
            }
            catch (Exception ex)
            {
                log.WarnFormat("Failed to instantiate type \"{0}\" from {1} - {2}.dll", assembly.FullName, assembly.FullName, ex.Message);
            }
        }
コード例 #5
0
        public void UnloadPlugin(IGUIPlugin plugin)
        {
            if (m_ActivePlugins.Contains(plugin))
            {
                log.Debug("Deactivate " + plugin.GetName());
                DeactivatePlugin(plugin);
            }

            if (m_DormantPlugins.Contains(plugin))
            {
                m_DormantPlugins.Remove(plugin);
            }
        }
コード例 #6
0
        public void DeactivatePlugin(IGUIPlugin plugin)
        {
            if (m_ActivePlugins.Contains(plugin))
            {
                try
                {
                    log.Debug("Deinitialize " + plugin.GetName());
                    plugin.Deinitialize();
                }
                catch (Exception ex)
                {
                    log.ErrorFormat("Failed to deactivate plugin \"{0} - {1}\" - {2}", plugin.GetName(), plugin.GetVersion(), ex.Message);
                    return;
                }

                m_DormantPlugins.Add(plugin);
                m_ActivePlugins.Remove(plugin);
                log.InfoFormat("Deactivated plugin \"{0} - {1}\"", plugin.GetName(), plugin.GetVersion());
            }
        }