public async Task InstallExtensions(IEnumerable<IExtensionModel> extensionModels)
{
bool hasInstalled = false;
int count = extensionModels.Count();
_progress = new InstallerProgress(count, $"Downloading and installing {count} extension(s)...");
_progress.Show();
await Task.Run(() =>
{
foreach (IExtensionModel model in extensionModels)
{
try
{
GalleryEntry entry = _repository.CreateQuery<GalleryEntry>(includeTypeInQuery: false, includeSkuInQuery: true, searchSource: "ExtensionManagerUpdate")
.Where(e => e.VsixID == model.ProductId)
.AsEnumerable()
.FirstOrDefault();
if (!_progress.IsVisible)
break;
if (entry != null)
{
IInstallableExtension installable = _repository.Download(entry);
if (!_progress.IsVisible)
break;
_manager.Install(installable, false);
hasInstalled = true;
var props = new Dictionary<string, string> { { "extension", model.Name } };
}
}
catch (Exception ex)
{
Logger.Log(ex);
}
}
});
if (_progress.IsVisible)
{
_progress.Close();
_progress = null;
}
if (hasInstalled)
PromptForRestart();
}