Ejemplo n.º 1
0
        private static void FromXmlNode(TreeCollection <T> treeCollection, ref TreeItemCollection <T> currentColl, XmlNode xnode, TreeItemXmlReaderDelegate readerDelegate)
        {
            XmlNodeList xlist = xnode.SelectNodes("./TreeItem");

            for (int i = 0; i < xlist.Count; i++)
            {
                XmlNode currentNode = xlist[i];

                TreeItem <T> newItem = currentColl.Add(treeCollection.GlobalCollection.CreateFreeKey(), default(T));

                readerDelegate(ref newItem, currentNode);

                if (currentNode.ChildNodes.Count > 0)
                {
                    TreeItemCollection <T> itemColl = newItem.Subitems;
                    FromXmlNode(treeCollection, ref itemColl, xlist[i], readerDelegate);
                }
            }
        }
Ejemplo n.º 2
0
        public static TreeCollection <T> FromXml(XmlDocument xdoc, TreeItemXmlReaderDelegate readerDelegate)
        {
            XmlNodeList        xlist    = xdoc.SelectNodes("TreeCollection//TreeItem");
            TreeCollection <T> treeColl = new TreeCollection <T>(xlist.Count);

            xlist = xdoc.SelectNodes("TreeCollection/TreeItem");

            for (int i = 0; i < xlist.Count; i++)
            {
                XmlNode currentNode = xlist[i];

                TreeItem <T> newItem = treeColl.Items.Add(treeColl.GlobalCollection.CreateFreeKey(), default(T));

                readerDelegate(ref newItem, currentNode);

                if (currentNode.ChildNodes.Count > 0)
                {
                    TreeItemCollection <T> currentColl = treeColl.Items;
                    FromXmlNode(treeColl, ref currentColl, xlist[i], readerDelegate);
                }
            }
            return(treeColl);
        }