private async System.Threading.Tasks.Task Install() { var repository = (IVsExtensionRepository)GetService(typeof(SVsExtensionRepository)); var manager = (IVsExtensionManager)GetService(typeof(SVsExtensionManager)); var store = new DataStore(); var missing = GetMissingExtensions(manager, store); if (!missing.Any()) { return; } var allToBeInstalled = missing.ToArray(); var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); var hwnd = new IntPtr(dte.MainWindow.HWnd); var window = (Window)System.Windows.Interop.HwndSource.FromHwnd(hwnd).RootVisual; var dialog = new InstallerProgress(missing, $"Downloading extensions..."); dialog.Owner = window; dialog.Show(); await System.Threading.Tasks.Task.Run(() => { foreach (var product in allToBeInstalled) { if (!dialog.IsVisible) { break; // User canceled the dialog } dialog.StartDownloading(product.Key); dialog.SetMessage($"Installing {product.Value}..."); InstallExtension(repository, manager, product, store); dialog.InstallComplete(product.Key); } store.Save(); }); if (dialog != null && dialog.IsVisible) { dialog.Close(); dialog = null; PromptForRestart(allToBeInstalled.Select(ext => ext.Value)); } }
private async System.Threading.Tasks.Task Install() { var repository = (IVsExtensionRepository)GetService(typeof(SVsExtensionRepository)); var manager = (IVsExtensionManager)GetService(typeof(SVsExtensionManager)); var installed = manager.GetInstalledExtensions(); var products = ExtensionList.Products(); var missing = products.Where(product => !installed.Any(ins => ins.Header.Identifier == product.Key)); if (!missing.Any()) { return; } var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); var hwnd = new IntPtr(dte.MainWindow.HWnd); var window = (Window)System.Windows.Interop.HwndSource.FromHwnd(hwnd).RootVisual; var dialog = new InstallerProgress(missing, $"Downloading extensions..."); dialog.Owner = window; dialog.Show(); await System.Threading.Tasks.Task.Run(() => { foreach (var product in missing) { if (!dialog.IsVisible) { break; // User cancelled the dialog } dialog.StartDownloading(product.Key); dialog.SetMessage($"Installing {product.Value}..."); InstallExtension(repository, manager, product); dialog.InstallComplete(product.Key); } }); if (dialog.IsVisible) { dialog.Close(); dialog = null; PromptForRestart(); } }
private async System.Threading.Tasks.Task Install() { var repository = (IVsExtensionRepository)GetService(typeof(SVsExtensionRepository)); var manager = (IVsExtensionManager)GetService(typeof(SVsExtensionManager)); var store = new DataStore(); var missing = GetMissingExtensions(manager, store); if (!missing.Any()) return; var allToBeInstalled = missing.ToArray(); var dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); var hwnd = new IntPtr(dte.MainWindow.HWnd); var window = (Window)System.Windows.Interop.HwndSource.FromHwnd(hwnd).RootVisual; var dialog = new InstallerProgress(missing, $"Downloading extensions..."); dialog.Owner = window; dialog.Show(); await System.Threading.Tasks.Task.Run(() => { foreach (var product in allToBeInstalled) { if (!dialog.IsVisible) break; // User canceled the dialog dialog.StartDownloading(product.Key); dialog.SetMessage($"Installing {product.Value}..."); InstallExtension(repository, manager, product, store); dialog.InstallComplete(product.Key); } store.Save(); }); if (dialog != null && dialog.IsVisible) { dialog.Close(); dialog = null; PromptForRestart(allToBeInstalled.Select(ext => ext.Value)); } }
private async System.Threading.Tasks.Task Install() { var repository = (IVsExtensionRepository)GetService(typeof(SVsExtensionRepository)); var manager = (IVsExtensionManager)GetService(typeof(SVsExtensionManager)); var installed = manager.GetInstalledExtensions(); var products = ExtensionList.Products(); var missing = products.Where(product => !installed.Any(ins => ins.Header.Identifier == product.Key)); if (!missing.Any()) return; var progress = new InstallerProgress(missing.Count() + 1, $"Downloading extensions..."); progress.Show(); await System.Threading.Tasks.Task.Run(() => { foreach (var product in missing) { progress.AddExtension(product.Key, product.Value); } foreach (var product in missing) { if (!progress.IsVisible) break; // User cancelled the dialog progress.StartDownloading(product.Key); progress.SetMessage($"Installing {product.Value}..."); InstallExtension(repository, manager, product); progress.InstallComplete(product.Key); } }); if (progress.IsVisible) { progress.Close(); progress = null; PromptForRestart(); } }