protected override void Initialize(UpdatingContext context) { context.OverrideSettings <SettingsOverride>((originalSettings, settingsOverride) => { originalSettings.DebugMode = settingsOverride.DebugMode; originalSettings.PatcherUpdaterSafeMode = settingsOverride.PatcherUpdaterSafeMode; }); NetworkChecker = new NetworkChecker(); _repairer = new Repairer(context); _repairer.Downloader.DownloadComplete += Data.DownloadComplete; _updater = new Updater(context); _updater.Downloader.DownloadComplete += Data.DownloadComplete; context.RegisterUpdateStep(_repairer); context.RegisterUpdateStep(_updater); context.Runner.PerformedStep += (sender, updater) => { if (context.IsDirty(out var reasons, out var data)) { var stringReasons = ""; foreach (var reason in reasons) { stringReasons += $"{reason}, "; } stringReasons = stringReasons.Substring(0, stringReasons.Length - 2); context.Logger.Debug($"Context is set to dirty: updater restart required. The files {stringReasons} have been replaced."); if (data.Count > 0) { if (data[0] is UpdaterSafeModeDefinition) { var definition = (UpdaterSafeModeDefinition)data[0]; UpdateRestartNeeded(definition.ExecutableToRun); return; } } UpdateRestartNeeded(); } }; }
protected override void Initialize(UpdatingContext context) { _repairer = new Repairer(context); _repairer.Downloader = new SmartDownloader(); _repairer.Downloader.DownloadComplete += Data.DownloadComplete; _repairer.Downloader.ProgressChanged += Data.DownloadProgressChanged; _updater = new Updater(context); _updater.Downloader.DownloadComplete += Data.DownloadComplete; _updater.Downloader.ProgressChanged += Data.DownloadProgressChanged; context.RegisterUpdateStep(_repairer); context.RegisterUpdateStep(_updater); context.Runner.PerformedStep += (sender, updater) => { if (context.IsDirty(out var reasons)) { context.Logger.Debug("Context is set to dirty: updater restart required. The files {DirtyFiles} have been replaced.", reasons); UpdateRestartNeeded(); } }; }
protected override void Initialize(UpdatingContext context) { context.OverrideSettings <SettingsOverride>((originalSettings, settingsOverride) => { originalSettings.DebugMode = settingsOverride.DebugMode; originalSettings.PatcherUpdaterSafeMode = settingsOverride.PatcherUpdaterSafeMode; }); context.Downloader.DownloadComplete += Data.DownloadComplete; NetworkChecker = new NetworkChecker(); _patcherUpdater = new PatcherUpdater(context); context.RegisterUpdateStep(_patcherUpdater); context.Runner.PerformedStep += (sender, updater) => { if (context.IsDirty(out var reasons, out var data)) { var stringReasons = ""; foreach (var reason in reasons) { stringReasons += $"{reason}, "; } stringReasons = stringReasons.Substring(0, stringReasons.Length - 2); context.Logger.Debug( $"Context is set to dirty: updater restart required. The files {stringReasons} have been replaced."); if (data.Count > 0) { if (data[0] is UpdaterSafeModeDefinition) { var definition = (UpdaterSafeModeDefinition)data[0]; UpdateRestartNeeded(definition.ExecutableToRun); return; } } UpdateRestartNeeded(); } }; _timeFromLastCheck = TimeBetweenEachCheckInSeconds; _isPreviousUpdateCompleted = true; Data.ProgressBar.gameObject.SetActive(false); }