Exemple #1
0
        void downloadUpdates()
        {
            State = "ProgressState";

            var updateManager = getUpdateManager();

            updateManager.DownloadReleases(UpdateInfo.ReleasesToApply, progress)
            // always be disposing
            .Finally(updateManager.Dispose)
            .Catch <Unit, Exception>(ex => {
                UserError.Throw(new UserError("Something unexpected happened", innerException: ex));
                return(Observable.Return(Unit.Default));
            })
            // this next line isn't necessary in The Real World
            // but i'm adding it here to emphasize
            // the progress bar that you get here
            .Delay(TimeSpan.FromSeconds(1.5))
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(_ =>
            {
                var viewModel        = getApplyViewModel.Value;
                viewModel.UpdateInfo = UpdateInfo;
                HostScreen.Navigate(viewModel);
            });
        }
        void checkForUpdates()
        {
            State = "ProgressState";

            if (!settingsProvider.IsUpdateLocationSet)
            {
                UserError.Throw("You haven't specified where the updates are located. Go back to the settings menu.");
                return;
            }

            var updateManager = getUpdateManager();

            updateManager.CheckForUpdate(!UseDeltaPackages, progress)
            .Catch <UpdateInfo, SquirrelConfigurationException>(ex => {
                UserError.Throw(new UserError("Something unexpected happened", innerException: ex));
                return(Observable.Return <UpdateInfo>(null));
            })
            // always be disposing
            .Finally(updateManager.Dispose)
            // this next line isn't necessary in The Real World
            // but i'm adding it here to emphasize
            // the progress bar that you get here
            .Delay(TimeSpan.FromSeconds(1.5))
            .ObserveOn(SynchronizationContext.Current)
            .Subscribe(updateInfo => {
                if (updateInfo == null)
                {
                    return;
                }
                if (updateInfo.ReleasesToApply.Any())
                {
                    var viewModel        = getDownloadViewModel.Value;
                    viewModel.UpdateInfo = updateInfo;
                    HostScreen.Navigate(viewModel);
                }
                else
                {
                    State = "NoChangesState";
                }
            });
        }