DeleteSection() public method

public DeleteSection ( string section ) : bool
section string
return bool
Beispiel #1
0
        public bool DeleteSection(string section)
        {
            // machine wide settings cannot be changed.
            if (IsMachineWideSettings)
            {
                if (_next == null)
                {
                    throw new InvalidOperationException(NuGetResources.Error_NoWritableConfig);
                }

                return(_next.DeleteSection(section));
            }

            if (String.IsNullOrEmpty(section))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "section");
            }

            var sectionElement = GetSection(_config.Root, section);

            if (sectionElement == null)
            {
                return(false);
            }

            sectionElement.RemoveIndented();
            Save();
            return(true);
        }