public bool DeleteSection(string section) { // machine wide settings cannot be changed. if (IsMachineWideSettings) { if (_next == null) { throw new InvalidOperationException(Resources.Error_NoWritableConfig); } return(_next.DeleteSection(section)); } if (String.IsNullOrEmpty(section)) { throw new ArgumentException(Resources.Argument_Cannot_Be_Null_Or_Empty, nameof(section)); } var sectionElement = GetSection(ConfigXDocument.Root, section); if (sectionElement == null) { return(false); } XElementUtility.RemoveIndented(sectionElement); Save(); return(true); }
/// <summary> /// Saves the <paramref name="source"/> as the active source. /// </summary> /// <param name="source"></param> public void SaveActivePackageSource(PackageSource source) { try { Settings.DeleteSection(ConfigurationContants.ActivePackageSourceSectionName); Settings.SetValue(ConfigurationContants.ActivePackageSourceSectionName, source.Name, source.Source); } catch (Exception) { // we want to ignore all errors here. } }