Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        protected override void Initialize(UpdatingContext context)
        {
            _patcherUpdater            = new PatcherUpdater(context);
            _patcherUpdater.Downloader = new SmartDownloader();
            _patcherUpdater.Downloader.DownloadComplete += Data.DownloadComplete;
            _patcherUpdater.Downloader.ProgressChanged  += Data.DownloadProgressChanged;

            context.RegisterUpdateStep(_patcherUpdater);

            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();
                }
            };
        }