// check for updates for the matched template, based on the Identity private async Task CheckForTemplateUpdateAsync() { if (!_settingsLoader.InstallUnitDescriptorCache.TryGetDescriptorForTemplate(_templateToInvoke.Info, out IInstallUnitDescriptor descriptor)) { Reporter.Error.WriteLine(string.Format(LocalizableStrings.InstallDescriptor_NotFound, _templateToInvoke.Info.Identity)); return; } List <IInstallUnitDescriptor> descriptorList = new List <IInstallUnitDescriptor>() { descriptor }; TemplateUpdateChecker updateChecker = new TemplateUpdateChecker(_environment); IUpdateCheckResult updateCheckResult = await updateChecker.CheckForUpdatesAsync(descriptorList); if (updateCheckResult.Updates.Count == 0) { return; } else if (updateCheckResult.Updates.Count == 1) { DisplayUpdateMessage(updateCheckResult.Updates[0]); } else { Reporter.Error.WriteLine(string.Format(LocalizableStrings.UpdateCheck_UnknownError, descriptor.Identifier)); } }
public async void UpdateTemplates(IReadOnlyList <IInstallUnitDescriptor> installUnitsToCheck, Func <string> inputGetter, bool applyAll = false) { IReadOnlyList <IUpdateUnitDescriptor> updateDescriptorList = await _updateChecker.CheckForUpdatesAsync(installUnitsToCheck); if (updateDescriptorList.Count == 0) { DisplayNoUpdatesFoundMessage(); return; } ListUpdates(updateDescriptorList); ApplyUpdatesChoice allUpdatesChoice; if (applyAll) { allUpdatesChoice = ApplyUpdatesChoice.All; } else { allUpdatesChoice = GetUserChoiceForAllUpdates(inputGetter); } switch (allUpdatesChoice) { case ApplyUpdatesChoice.None: return; case ApplyUpdatesChoice.All: ApplyUpdates(updateDescriptorList); break; case ApplyUpdatesChoice.Prompt: foreach (IUpdateUnitDescriptor descriptor in updateDescriptorList) { bool shouldUpdate = GetUserChoiceForIndividualUpdate(descriptor, inputGetter); if (shouldUpdate) { ApplyUpdates(new List <IUpdateUnitDescriptor>() { descriptor }); } } break; } }