public void DeleteValue(string section, string key)
{
if (String.IsNullOrEmpty(section)) {
throw new ArgumentException("Argument cannot be null or empty.", "section");
}
if (String.IsNullOrEmpty(key)) {
throw new ArgumentException("Argument cannot be null or empty.", "key");
}
var sectionElement = _config.Root.Element(section);
if (sectionElement == null) {
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.UserSettings_SectionDoesNotExist, section));
}
XElement elementToDelete = null;
foreach (var e in sectionElement.Elements("add")) {
if (e.GetOptionalAttributeValue("key") == key) {
elementToDelete = e;
break;
}
}
if (elementToDelete == null) {
throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, NuGetResources.UserSettings_SectionDoesNotExist, section));
}
elementToDelete.Remove();
Save(_config);
}