public void GetRemotePluginListTest()
        {
            string pluginDir = Environment.CurrentDirectory;

            try {
                InstallationManager target = new InstallationManager(pluginDir);
                var pluginList             = target.GetRemotePluginList();
                Assert.IsTrue(pluginList != null);
            } catch (Exception e) {
                Assert.Fail("Connection to the update service failed. " + e.Message);
            }
        }
예제 #2
0
        private void CheckUpdatesAvailableAsync()
        {
            string pluginPath = Path.GetFullPath(Application.StartupPath);
            var    task       = Task.Factory.StartNew <bool>(() => {
                var installationManager = new InstallationManager(pluginPath);
                IEnumerable <IPluginDescription> installedPlugins = pluginManager.Plugins.OfType <IPluginDescription>();
                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 Util.IsNewerThan(remotePlugin, installedPlugin)
                                                                 select installedPlugin
                                                                 where matchingLocalPlugins.Count() > 0
                                                                 select remotePlugin;
                return(pluginsToUpdate.Count() > 0);
            });

            task.ContinueWith(t => {
                try {
                    t.Wait();
                    updatesAvailable = t.Result;
                    UpdateApplicationsList();
                }
                catch (AggregateException ae) {
                    ae.Handle(ex => {
                        if (ex is InstallationManagerException)
                        {
                            // this is expected when no internet connection is available => do nothing
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    });
                }
            });
        }