Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

store settings in a setting node rather than a node named after the s…

…etting's name (cleaner)
  • Loading branch information...
commit 95dd2266147309aa4095fdd0e276b40a8747c802 1 parent 3a3e80b
@crdx authored
Showing with 10 additions and 11 deletions.
  1. +10 −11 src/PortableSettingsProvider.cs
View
21 src/PortableSettingsProvider.cs
@@ -137,13 +137,20 @@ private void SetValue(SettingsPropertyValue propertyValue)
? _globalSettingsNode
: _localSettingsNode;
- XmlNode settingNode = targetNode.SelectSingleNode(propertyValue.Name);
+ XmlNode settingNode = targetNode.SelectSingleNode(string.Format("setting[@name='{0}']", propertyValue.Name));
if (settingNode != null)
settingNode.InnerText = propertyValue.SerializedValue.ToString();
else
{
- settingNode = CreateTextElement(propertyValue.Name, propertyValue.SerializedValue.ToString());
+ settingNode = _rootDocument.CreateElement("setting");
+
+ XmlAttribute nameAttribute = _rootDocument.CreateAttribute("name");
+ nameAttribute.Value = propertyValue.Name;
+
+ settingNode.Attributes.Append(nameAttribute);
+ settingNode.InnerText = propertyValue.SerializedValue.ToString();
+
targetNode.AppendChild(settingNode);
}
}
@@ -151,7 +158,7 @@ private void SetValue(SettingsPropertyValue propertyValue)
private string GetValue(SettingsProperty property)
{
XmlNode targetNode = IsGlobal(property) ? _globalSettingsNode : _localSettingsNode;
- XmlNode settingNode = targetNode.SelectSingleNode(property.Name);
+ XmlNode settingNode = targetNode.SelectSingleNode(string.Format("setting[@name='{0}']", property.Name));
if (settingNode == null)
return property.DefaultValue != null ? property.DefaultValue.ToString() : string.Empty;
@@ -170,14 +177,6 @@ private bool IsGlobal(SettingsProperty property)
return false;
}
- private XmlNode CreateTextElement(string name, string innerText)
- {
- XmlNode xmlElement = _rootDocument.CreateElement(name);
- xmlElement.InnerText = innerText;
-
- return xmlElement;
- }
-
private XmlNode GetSettingsNode(string name)
{
XmlNode settingsNode = _rootNode.SelectSingleNode(name);
Please sign in to comment.
Something went wrong with that request. Please try again.