void updatePluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { IEnumerable <IPluginDescription> installedPlugins = (IEnumerable <IPluginDescription>)e.Argument; var remotePlugins = installationManager.GetRemotePluginList(); // if there is a local plugin with same name and same major and minor version then it's an update var pluginsToUpdate = from remotePlugin in remotePlugins let matchingLocalPlugins = from installedPlugin in installedPlugins where installedPlugin.Name == remotePlugin.Name where installedPlugin.Version.Major == remotePlugin.Version.Major where installedPlugin.Version.Minor == remotePlugin.Version.Minor where IsNewerThan(remotePlugin, installedPlugin) select installedPlugin where matchingLocalPlugins.Count() > 0 select remotePlugin; if (pluginsToUpdate.Count() > 0) { bool cancelled; installationManager.Update(pluginsToUpdate, out cancelled); if (!cancelled) { pluginManager.DiscoverAndCheckPlugins(); } e.Cancel = false; } else { e.Cancel = true; } }
void updateOrInstallPluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { UpdateOrInstallPluginsBackgroundWorkerArgument info = (UpdateOrInstallPluginsBackgroundWorkerArgument)e.Argument; bool cancelled = false; if (info.PluginsToInstall.Count() > 0) installationManager.Install(info.PluginsToInstall, out cancelled); if (info.PluginsToUpdate.Count() > 0) installationManager.Update(info.PluginsToUpdate, out cancelled); if (!cancelled && (info.PluginsToInstall.Count() > 0 || info.PluginsToUpdate.Count() > 0)) pluginManager.DiscoverAndCheckPlugins(); }