public bool DeleteValue(string section, string key)
{
// machine wide settings cannot be changed.
if (IsMachineWideSettings)
{
if (_next == null)
{
throw new InvalidOperationException(NuGetResources.Error_NoWritableConfig);
}
return(_next.DeleteValue(section, key));
}
if (String.IsNullOrEmpty(section))
{
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "section");
}
if (String.IsNullOrEmpty(key))
{
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "key");
}
var sectionElement = GetSection(_config.Root, section);
if (sectionElement == null)
{
return(false);
}
var elementToDelete = FindElementByKey(sectionElement, key, null);
if (elementToDelete == null)
{
return(false);
}
elementToDelete.RemoveIndented();
Save();
return(true);
}