public void CheckForUpdateOnStartup(IApplicationUpdateService service, ApplicationUpdatePresenterFactory presenterFactory) { if (Preferences.Get <bool>(Preference.StartupCheckForUpdate)) { CheckForUpdateInternal(service, presenterFactory); } }
private void CheckForUpdate(IApplicationUpdateService service, ApplicationUpdatePresenterFactory presenterFactory) { var result = CheckForUpdateInternal(service, presenterFactory); if (result.HasValue && !result.Value) { string text = $"{Core.Application.NameAndVersion} is already up-to-date."; MessageBox.ShowInformation(Form, text, Core.Application.NameAndVersion); } }
private bool?CheckForUpdateInternal(IApplicationUpdateService service, ApplicationUpdatePresenterFactory presenterFactory) { if (!Monitor.TryEnter(_checkForUpdateLock)) { return(null); } try { var uri = new Uri(Properties.Settings.Default.UpdateUrl); var update = service.GetApplicationUpdate(uri); if (update is null) { return(false); } if (!update.VersionIsGreaterThan(Core.Application.VersionNumber)) { return(false); } _applicationUpdateModel = new ApplicationUpdateModel(update); using (var presenter = presenterFactory.Create(_applicationUpdateModel)) { if (presenter.ShowDialog(Form) == DialogResult.OK) { if (_applicationUpdateModel.SelectedUpdateFileIsReadyToBeExecuted) { string text = String.Format(CultureInfo.CurrentCulture, "{0} will install the new version when you exit the application.", Core.Application.Name); MessageBox.ShowInformation(Form, text, Core.Application.NameAndVersion); } } } return(true); } finally { Monitor.Exit(_checkForUpdateLock); } }
public void CheckForUpdateClick(IApplicationUpdateService service, ApplicationUpdatePresenterFactory presenterFactory) { CheckForUpdate(service, presenterFactory); }