private void ReadFile(FileData fd, CancellationToken ct) { if (ct.IsCancellationRequested == true) { ct.ThrowIfCancellationRequested(); } using (FileStream fs = new FileStream(fd.FileFullName, FileMode.Open)) { XmlDocument xd = new XmlDocument(); xd.Load(fs); XmlElement el = xd.DocumentElement; TreeViewModel root = new TreeViewModel() { IsExpanded = true, Node = el, Owner = this }; if (!root.AttachPlugin()) { IterateXml(root, el); } fd.Items.Add(root); } }
private void IterateXml(TreeViewModel tvm, XmlNode el) { foreach (XmlNode nd in el.ChildNodes) { TreeViewModel item = new TreeViewModel() { Node = nd, Owner = this, Parent = tvm }; if (!item.AttachPlugin()) { IterateXml(item, nd); } tvm.Items.Add(item); } }