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);
}
}
}