/// <summary> /// Persist the package sources, which was add/removed via the Options page, to the VS Settings store. /// This gets called when users click OK button. /// </summary> internal bool ApplyChangedSettings() { // if user presses Enter after filling in Name/Source but doesn't click Update // the options will be closed without adding the source, try adding before closing // Only apply if nothing was added TryUpdateSourceResults result = TryUpdateSource(); if (result != TryUpdateSourceResults.NotUpdated && result != TryUpdateSourceResults.Unchanged) { return(false); } // get package sources as ordered list var packageSources = PackageSourcesListBox.Items.Cast <PackageSource>().ToList(); packageSources.AddRange(MachineWidePackageSourcesListBox.Items.Cast <PackageSource>().ToList()); var existingSources = _packageSourceProvider.LoadPackageSources().ToList(); if (SourcesChanged(existingSources, packageSources)) { _packageSourceProvider.SavePackageSources(packageSources); } // find the enabled package source var updatedActiveSource = packageSources.Find(p => p.IsEnabled); return(true); }
/// <summary> /// Persist the package sources, which was add/removed via the Options page, to the VS Settings store. /// This gets called when users click OK button. /// </summary> internal bool ApplyChangedSettings() { // if user presses Enter after filling in Name/Source but doesn't click Update // the options will be closed without adding the source, try adding before closing // Only apply if nothing was added TryUpdateSourceResults result = TryUpdateSource(); if (result != TryUpdateSourceResults.NotUpdated && result != TryUpdateSourceResults.Unchanged) { return(false); } // get package sources as ordered list var packageSources = PackageSourcesListBox.Items.Cast <PackageSource>().ToList(); packageSources.AddRange(MachineWidePackageSourcesListBox.Items.Cast <PackageSource>().ToList()); _packageSourceProvider.SavePackageSources(packageSources); // Update the shim UpdateShimControllerSources(); // find the enabled package source var updatedActiveSource = packageSources.Find(p => p.IsEnabled && p.Equals(_activeSource)); // restore current active source if it still exists, or reset to aggregate source _packageSourceProvider.ActivePackageSource = updatedActiveSource ?? AggregatePackageSource.Instance; return(true); }
private void OnUpdateButtonClick(object sender, EventArgs e) { TryUpdateSourceResults result = TryUpdateSource(); if (result == TryUpdateSourceResults.NotUpdated) { MessageHelper.ShowWarningMessage(Resources.ShowWarning_NameAndSourceRequired, Resources.ShowWarning_Title); SelectAndFocus(NewPackageName); } }
/// <summary> /// Persist the package sources, which was add/removed via the Options page, to the VS Settings store. /// This gets called when users click OK button. /// </summary> internal bool ApplyChangedSettings() { // if user presses Enter after filling in Name/Source but doesn't click Update // the options will be closed without adding the source, try adding before closing // Only apply if nothing was added TryUpdateSourceResults result = TryUpdateSource(); if (result != TryUpdateSourceResults.NotUpdated && result != TryUpdateSourceResults.Unchanged) { return(false); } // get package sources as ordered list var packageSources = PackageSourcesListBox.Items.Cast <Configuration.PackageSource>().ToList(); packageSources.AddRange(MachineWidePackageSourcesListBox.Items.Cast <Configuration.PackageSource>().ToList()); try { var existingSources = _packageSourceProvider.LoadPackageSources().ToList(); if (SourcesChanged(existingSources, packageSources)) { _packageSourceProvider.SavePackageSources(packageSources); } } catch (Configuration.NuGetConfigurationException e) { MessageHelper.ShowErrorMessage(ExceptionUtilities.DisplayMessage(e), Resources.ErrorDialogBoxTitle); return(false); } // find the enabled package source return(true); }