Beispiel #1
0
        public static void RefreshPlugins()
        {
            // Read in the Assemblies to refresh
            string[] enabled = Config.Plugin.Enabled;
            List <PluginAssembly> asmsToRefresh = ReadAssemblyPaths().Select(path => {
                PluginAssembly asm;
                if (!GetAssembly(path, out asm))
                {
                    return(LoadAssembly(path));
                }
                foreach (PluginInformation info in asm.PluginInformations
                         .Where(info => enabled.Contains(info.PluginID)))
                {
                    info.Enabled = true;
                    asm.Enabled  = true;
                }
                return(asm);
            }).ToList();

            // Uninstall the currently installed Assemblies that aren't in the new list
            foreach (PluginAssembly asm in PluginAssemblies.Except(asmsToRefresh).ToList())
            {
                UninstallPluginAssembly(asm);
            }

            // Make a list of PluginIDs that are disabled and disable them
            List <string> pidsToUnload = asmsToRefresh.SelectMany(asm => asm.PluginInformations)
                                         .Where(pi => !pi.Enabled).Select(pi => pi.PluginID).ToList();

            foreach (string pid in pidsToUnload)  // static
            {
                Plugin plugin;
                if (!dicStaticPluginInstances.TryGetValue(pid, out plugin))
                {
                    continue;
                }
                if (plugin.PluginInformation.PluginType == PluginType.Static)
                {
                    plugin.Close(EndCode.Removed);
                }
                dicStaticPluginInstances.Remove(pid);
            }
            ClearIEncodingDetector();

            // Refresh the existing ones.
            foreach (PluginAssembly pa in asmsToRefresh)
            {
                foreach (PluginInformation info in pa.PluginInformations)
                {
                    if (info.Enabled)
                    {
                        LoadStaticInstance(info, pa);
                    }
                }
            }
            InstanceManager.LocalTabBroadcast(tabbar => tabbar.pluginServer.RefreshPlugins());
        }
Beispiel #2
0
 public static void UpdateConfig(bool fBroadcast = true)
 {
     QTUtility.TextResourcesDic = Config.Lang.UseLangFile && File.Exists(Config.Lang.LangFile)
             ? QTUtility.ReadLanguageFile(Config.Lang.LangFile)
             : null;
     QTUtility.ValidateTextResources();
     StaticReg.ClosedTabHistoryList.MaxCapacity = Config.Misc.TabHistoryCount;
     StaticReg.ExecutedPathsList.MaxCapacity    = Config.Misc.FileHistoryCount;
     DropDownMenuBase.InitializeMenuRenderer();
     ContextMenuStripEx.InitializeMenuRenderer();
     PluginManager.RefreshPlugins();
     InstanceManager.LocalTabBroadcast(tabbar => tabbar.RefreshOptions());
     if (fBroadcast)
     {
         // SyncTaskBarMenu(); todo
         InstanceManager.StaticBroadcast(() => {
             ReadConfig();
             UpdateConfig(false);
         });
     }
 }
Beispiel #3
0
        public static void UninstallPluginAssembly(PluginAssembly pa)
        {
            List <string> pids = pa.PluginInformations.Select(pi => pi.PluginID).ToList();

            InstanceManager.LocalTabBroadcast(tabbar => pids.ForEach(pid =>
                                                                     tabbar.pluginServer.UnloadPluginInstance(pid, EndCode.Removed)));

            foreach (PluginInformation info in pa.PluginInformations)
            {
                Plugin plugin;
                if (!dicStaticPluginInstances.TryGetValue(info.PluginID, out plugin))
                {
                    continue;
                }
                if (info.PluginType == PluginType.Static)
                {
                    plugin.Close(EndCode.Removed);
                }
                dicStaticPluginInstances.Remove(info.PluginID);
            }
            dicPluginAssemblies.Remove(pa.Path);
            pa.Uninstall();
            pa.Dispose();
        }