public InterceptedStringCollection GetSettingsValueStringCollection(string name, InterceptedStringCollection defaultValue) { InterceptedStringCollection result = new InterceptedStringCollection(this, name); string xmlDoc = GetSettingsValue(name, null); if (!string.IsNullOrEmpty(xmlDoc)) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xmlDoc); var root = doc.DocumentElement; var lines = root.SelectNodes("entry"); foreach (XmlNode n in lines) { result.AddWithoutSave(n.InnerText); } } return result; }
public void SetSettingsValueStringCollection(string name, InterceptedStringCollection value) { if (value == null) { SetSettingsValue(name, ""); } else { XmlDocument doc = new XmlDocument(); XmlElement root = doc.CreateElement("root"); doc.AppendChild(root); foreach (var l in value) { XmlElement el = doc.CreateElement("entry"); XmlText txt = doc.CreateTextNode(l); el.AppendChild(txt); root.AppendChild(el); } /* using (var stringWriter = new StringWriter()) using (var xmlTextWriter = XmlWriter.Create(stringWriter)) { doc.WriteTo(xmlTextWriter); xmlTextWriter.Flush(); SetSettingsValue(name, stringWriter.GetStringBuilder().ToString()); } * */ SetSettingsValue(name, doc.OuterXml); } }