Exemplo n.º 1
0
        /// <summary>
        /// Write the next BNL node.
        /// </summary>
        /// <param name="node">Node to write.</param>
        public void Next(BnlNode node)
        {
            if (headIndex == -1)
            {
                headIndex = writer.BaseStream.Position;
                writer.Seek(16, SeekOrigin.Current);
            }

            if (node is null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            node.Serialize(writer);
            Count++;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read the next node from the stream.
        /// </summary>
        /// <returns>The next node.</returns>
        public BnlNode Next()
        {
            if (!headRead)
            {
                ReadHeader();
            }

            if (Left < 0)
            {
                throw new Exception("No more nodes left to read.");
            }

            BnlNode node = new BnlNode();

            node.Deserialize(reader);
            Left--;
            return(node);
        }