예제 #1
0
        /// <summary>
        /// Saves the node and the children.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="writer">The writer.</param>
        private void SaveNode(HelpNode node, BinaryWriter writer)
        {
            writer.Write(node.Name);
            writer.Write(node.Children.Count);

            node.Children.ForEach(child => {
                SaveNode(child, writer);
            });
        }
예제 #2
0
        /// <summary>
        /// Loads the node and subsequent child nodes from the reader.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="reader">The reader.</param>
        private void LoadNode(HelpNode node, BinaryReader reader)
        {
            node.Name = reader.ReadString();
            int nodeCount = reader.ReadInt32();

            for (int i = 0; i < nodeCount; i++)
            {
                HelpNode child = new HelpNode();
                LoadNode(child, reader);

                node.Children.Add(child);
            }
        }
예제 #3
0
        /// <summary>
        /// Tests the two nodes by comparing the names and the children.
        /// </summary>
        /// <param name="nodeA">The first node.</param>
        /// <param name="nodeB">The second node.</param>
        private void TestNodes(HelpNode nodeA, HelpNode nodeB)
        {
            Assert.AreEqual(nodeA.Name, nodeB.Name, "Node name values do not match");
            Assert.AreEqual(nodeA.Children.Count, nodeB.Children.Count, "Child counts do not match");

            for (int i = 0; i < nodeA.Children.Count; i++) {
                TestNodes(nodeA.Children[i], nodeA.Children[i]);
            }
        }
예제 #4
0
 /// <summary>
 /// Removes all nodes and pages.
 /// </summary>
 public void Clear()
 {
     RootNode = new HelpNode();
     Pages.Clear();
 }