internal static void LoadPlugins(bool bReload) { lock (Plugins) //Might be called in multiple threads, ensure a plugin is listed only once { if (!bReload && Plugins.Count > 0) { return; } Plugins.Clear(); if (m_Plugins.Count == 0) { m_Plugins = Tools.GetLoadedPluginsName(); } if (Plugins.Count > 0) { return; //Might have been filled from different thread meanwhile } List <string> lPluginnames = new List <string>(); foreach (string sPlugin in m_Plugins.Keys) { try { string s = sPlugin.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries)[0]; Plugin p = (Plugin)Tools.GetPluginInstance(s); if (p == null) { continue; } AssemblyCompanyAttribute[] comp = (AssemblyCompanyAttribute[])p.GetType().Assembly.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false); bool bOwnPlugin = string.Compare("rookiestyle", comp[0].Company, StringComparison.InvariantCultureIgnoreCase) == 0; PluginUpdate pu = null; if (bOwnPlugin) { pu = new OwnPluginUpdate(p.GetType().Namespace); } else { try { pu = new OtherPluginUpdate(p.GetType().Namespace); } catch { } } if (pu != null && Plugins.Find(x => x.Name == pu.Name) == null) { Plugins.Add(pu); if (pu.UpdatePossible) { lPluginnames.Add(pu.Name); } } } catch (Exception ex) { PluginDebug.AddError(ex.Message, 0); } } PluginDebug.AddInfo("Installed updatable plugins", 0, lPluginnames.ToArray()); } }
private void bUpdateTranslations_Click(object sender, EventArgs e) { List <OwnPluginUpdate> lPlugins = new List <OwnPluginUpdate>(); foreach (PluginUpdate pu in PluginUpdateHandler.Plugins) { OwnPluginUpdate opu = pu as OwnPluginUpdate; if (opu == null) { continue; } if (!PluginUpdateHandler.VersionsEqual(pu.VersionInstalled, pu.VersionAvailable)) { continue; } if (opu.Translations.Count == 0) { continue; } if (!lPlugins.Contains(opu)) { lPlugins.Add(opu); } } if (lPlugins.Count == 0) { PluginTools.PluginDebug.AddInfo("No plugins where translations can be updated", 0); return; } using (TranslationUpdateForm t = new TranslationUpdateForm()) { t.InitEx(lPlugins); if (t.ShowDialog() == DialogResult.OK) { Plugin.UpdatePluginTranslations(PluginConfig.DownloadActiveLanguage, t.SelectedPlugins); } } }
private int SortOwnPluginUpdate(OwnPluginUpdate a, OwnPluginUpdate b) { return(-1 * string.Compare(a.Name, b.Name)); }