AccidentalFish.ApplicationSupport.Powershell.ConfigAppliers.CscfgConfigurationApplier.ApplyConfigSetting C# (CSharp) Method

ApplyConfigSetting() private method

private ApplyConfigSetting ( System.Xml.Linq.XElement configurationSettings, string key, string value ) : void
configurationSettings System.Xml.Linq.XElement
key string
value string
return void
        private void ApplyConfigSetting(XElement configurationSettings, string key, string value)
        {
            XNamespace ns = CscfgNamespace;
            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(new NameTable());
            namespaceManager.AddNamespace("cscfg", CscfgNamespace);
            string xpath = String.Format("cscfg:Setting[@name='{0}']", key);
            XElement appSetting = configurationSettings.XPathSelectElement(xpath, namespaceManager);
            if (appSetting == null)
            {
                appSetting = new XElement(ns + "Setting", new XAttribute("name", key), new XAttribute("value", value));
                configurationSettings.Add(appSetting);
            }
            else
            {
                appSetting.SetAttributeValue("value", value);
            }
        }
    }