public bool IsPackageSourceEnabled(string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException(Resources.Argument_Cannot_Be_Null_Or_Empty, nameof(name)); } var disabledSources = Settings.GetSection(ConfigurationConstants.DisabledPackageSources); var value = disabledSources?.GetFirstItemWithAttribute <AddItem>(ConfigurationConstants.KeyAttribute, name); // It doesn't matter what value it is. // As long as the package source name is persisted in the <disabledPackageSources> section, the source is disabled. return(value == null); }
/// <summary> /// Saves the <paramref name="source" /> as the active source. /// </summary> /// <param name="source"></param> public void SaveActivePackageSource(PackageSource source) { try { var activePackageSourceSection = Settings.GetSection(ConfigurationConstants.ActivePackageSourceSectionName); if (activePackageSourceSection != null) { foreach (var activePackageSource in activePackageSourceSection.Items) { Settings.Remove(ConfigurationConstants.ActivePackageSourceSectionName, activePackageSource); } } Settings.AddOrUpdate(ConfigurationConstants.ActivePackageSourceSectionName, new AddItem(source.Name, source.Source)); Settings.SaveToDisk(); } catch (Exception) { // we want to ignore all errors here. } }