Ejemplo n.º 1
0
        /// <summary>
        /// Read nodes
        /// </summary>
        /// <param name="reader">The nodes</param>
        private void ReadNodes(BinaryReader reader)
        {
            // Nodes
            int nodeCount = reader.ReadInt32();

            this.Nodes = new NodeContent[nodeCount];
            for (int i = 0; i < nodeCount; i++)
            {
                this.Nodes[i] = NodeContent.Read(reader);
            }

            // Refresh node hierarchy
            for (int i = 0; i < nodeCount; i++)
            {
                var node = this.Nodes[i];
                if (node.ChildIndices != null)
                {
                    node.Children = new NodeContent[node.ChildIndices.Length];
                    for (int j = 0; j < node.ChildIndices.Length; j++)
                    {
                        var childNode = this.Nodes[node.ChildIndices[j]];
                        childNode.Parent = node;

                        node.Children[j] = childNode;
                    }
                }
            }

            // Root nodes
            int rootNodesCount = reader.ReadInt32();

            this.RootNodes = new int[rootNodesCount];
            for (int i = 0; i < rootNodesCount; i++)
            {
                this.RootNodes[i] = reader.ReadInt32();
            }
        }