public void UnloadPlugin(IGUIPlugin plugin)
        {
            if (m_ActivePlugins.Contains(plugin))
            {
                DeactivatePlugin(plugin);
            }

            if (m_DormantPlugins.Contains(plugin))
            {
                m_DormantPlugins.Remove(plugin);
            }
        }
Example #2
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);
            }
        }
        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());
            }
        }
Example #4
0
        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);
            }
        }
Example #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);
            }
        }
Example #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());
            }
        }