示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }