示例#1
0
 private void SetValueNodeContentsFromProp(SettingsPropertyValue propVal, XmlElement valueNode)
 {
     if (valueNode == null)
     {
         throw new ArgumentNullException("valueNode");
     }
     if (propVal.Property.SerializeAs == SettingsSerializeAs.String)
     {
         // In some cases the serialized value in the propVal can return null.
         // Set the contents of the setting xml to the empty string in that case.
         var serializedValue = propVal.SerializedValue;
         valueNode.InnerText = serializedValue != null?serializedValue.ToString() : String.Empty;
     }
     else if (propVal.Property.SerializeAs == SettingsSerializeAs.Xml)
     {
         if (!String.IsNullOrEmpty(propVal.SerializedValue as String))
         {
             var subDoc = new XmlDocument();
             subDoc.LoadXml((string)propVal.SerializedValue);
             if (valueNode.FirstChild != null)
             {
                 valueNode.RemoveChild(valueNode.FirstChild);
             }
             valueNode.AppendChild(SettingsXml.ImportNode(subDoc.DocumentElement, true));
         }
     }
     else
     {
         throw new NotImplementedException("CrossPlatformSettingsProvider does not yet handle settings of " +
                                           propVal.Property.SerializeAs);
     }
 }