static ClosedList() { Collection <ClosedList> coll = new Collection <ClosedList>(); if (File.Exists(listsFile)) { XmlDocument doc = new XmlDocument(); doc.Load(listsFile); XmlElement root = doc.DocumentElement; for (int i = 0; i < root.ChildNodes.Count; i++) { coll.Add(ClosedList.CreateFromXmlNode(root.ChildNodes[i])); } } ClosedLists = new ReadOnlyCollection <ClosedList>(coll); }
public static ClosedList CreateFromXmlNode(XmlNode xmlNode) { string netName = xmlNode.Attributes["Name"].Value; ClosedList result = new ClosedList(netName); XmlAttribute attr; for (int i = 0; i < xmlNode.ChildNodes.Count; i++) { XmlNode node = xmlNode.ChildNodes[i]; attr = node.Attributes["Word"]; if (attr != null && !string.IsNullOrEmpty(attr.Value)) { result.words.Add(attr.Value); } } return(result); }