NuGet.Settings.SetValueInternal C# (CSharp) Method

SetValueInternal() private method

private SetValueInternal ( System.Xml.Linq.XElement sectionElement, string key, string value ) : void
sectionElement System.Xml.Linq.XElement
key string
value string
return void
        private void SetValueInternal(XElement sectionElement, string key, string value)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "key");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            var element = FindElementByKey(sectionElement, key);
            if (element != null)
            {
                element.SetAttributeValue("value", value);
                Save();
            }
            else
            {
                sectionElement.Add(new XElement("add", 
                                                    new XAttribute("key", key), 
                                                    new XAttribute("value", value)));
            }
        }