private bool GetUserChoiceForIndividualUpdate(IUpdateUnitDescriptor descriptor, Func <string> inputGetter)
        {
            bool installChoice = false;
            bool validChoice   = false;

            do
            {
                Reporter.Output.WriteLine(string.Format(LocalizableStrings.SingleUpdateApplyPrompt.Bold().Red(), descriptor.UpdateDisplayInfo));

                string userChoice = inputGetter();

                switch (userChoice.ToLowerInvariant())
                {
                case "y":
                case "yes":
                    installChoice = true;
                    validChoice   = true;
                    break;

                case "n":
                case "no":
                    installChoice = false;
                    validChoice   = true;
                    break;

                default:
                    Reporter.Output.WriteLine(LocalizableStrings.ApplyUpdatesInvalidChoiceResponse.Bold().Red());
                    break;
                }
            } while (!validChoice);

            return(installChoice);
        }
示例#2
0
        public bool TryApplyUpdate(IUpdateUnitDescriptor updateDescriptor)
        {
            if (_updateChecker.TryGetUpdaterForDescriptorFactoryId(updateDescriptor.InstallUnitDescriptor.FactoryId, out IUpdater updater))
            {
                try
                {
                    updater.ApplyUpdates(_installer, new List <IUpdateUnitDescriptor>()
                    {
                        updateDescriptor
                    });
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }

            return(false);
        }
 private void DisplayUpdateMessage(IUpdateUnitDescriptor updateDescriptor)
 {
     Reporter.Output.WriteLine();
     Reporter.Output.WriteLine(string.Format(LocalizableStrings.UpdateAvailable, updateDescriptor.UpdateDisplayInfo));
     Reporter.Output.WriteLine(string.Format(LocalizableStrings.UpdateCheck_InstallCommand, _commandName, updateDescriptor.InstallString));
 }