Пример #1
0
 protected override void OnRestoreFailed(Exception ex, UpdateInformation updateInformation)
 {
     base.OnRestoreFailed(ex, updateInformation);
     Clean().Wait();
     if (LauncherRestartManager.ShowRestoreDialog(true))
     {
         var options = CreateRestoreRestartOptions();
         if (options is null)
         {
             throw ex;
         }
         ApplicationRestartManager.RestartApplication(options);
     }
     else
     {
         LauncherRegistryHelper.WriteValue(LauncherRegistryKeys.ForceRestore, true);
         Environment.Exit(-1);
     }
 }
        internal static bool Initialize(ExternalUpdaterResult launchOption)
        {
            if (!Directory.Exists(LauncherConstants.ApplicationBasePath))
            {
                throw new DirectoryNotFoundException($"Required directory '{LauncherConstants.ApplicationBasePath}' not found.");
            }

            SetupRegistry();

            try
            {
                if (CheckRestoreRequired(launchOption))
                {
                    Restore();
                }
                HandleLastUpdateResult(launchOption, out var skipWriteToDisk);
                if (!skipWriteToDisk)
                {
                    AssemblyExtractor.WriteNecessaryAssembliesToDisk(LauncherConstants.ApplicationBasePath, LauncherConstants.ApplicationFileNames);
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
                if (e is AggregateException aggregate)
                {
                    e = aggregate.GetBaseException();
                }
                LauncherRegistryHelper.WriteValue(LauncherRegistryKeys.ForceRestore, true);
                // TODO: This and the exception dialog should be the same dialog
                new RestartSystemDialog(e.Message).ShowDialog();
                Environment.Exit(0);
            }

            LogInstalledAssemblies();
            SetCurrentUpdateSearchMode();
            return(ShallUpdate(launchOption));
        }