Exemplo n.º 1
0
        private static void ReadTreeNode(SerializedFileReader reader, ICollection <TypeTreeNode> nodes, byte depth)
        {
            TypeTreeNode node = new TypeTreeNode(depth);

            node.Read(reader);
            nodes.Add(node);

            int childCount = reader.ReadInt32();

            for (int i = 0; i < childCount; i++)
            {
                ReadTreeNode(reader, nodes, (byte)(depth + 1));
            }
        }
Exemplo n.º 2
0
 public void Write(SerializedWriter writer)
 {
     if (TypeTreeNode.IsFormat5(writer.Generation))
     {
         writer.Write(Nodes.Length);
         writer.Write(CustomTypeBuffer.Length);
         for (int i = 0; i < Nodes.Length; i++)
         {
             Nodes[i].Write(writer);
         }
         writer.Write(CustomTypeBuffer, 0, CustomTypeBuffer.Length);
     }
     else
     {
         int index = 0;
         WriteTreeNode(writer, ref index);
     }
 }
Exemplo n.º 3
0
 public void Read(SerializedReader reader)
 {
     if (TypeTreeNode.IsFormat5(reader.Generation))
     {
         int nodesCount       = reader.ReadInt32();
         int customBufferSize = reader.ReadInt32();
         Nodes = new TypeTreeNode[nodesCount];
         for (int i = 0; i < nodesCount; i++)
         {
             Nodes[i].Read(reader);
         }
         CustomTypeBuffer = new byte[customBufferSize];
         reader.Read(CustomTypeBuffer, 0, CustomTypeBuffer.Length);
     }
     else
     {
         List <TypeTreeNode> nodes = new List <TypeTreeNode>();
         ReadTreeNode(reader, nodes, 0);
         Nodes = nodes.ToArray();
     }
 }
 public void Read(SerializedReader reader)
 {
     if (TypeTreeNode.IsFormat5(reader.Generation))
     {
         int nodesCount       = reader.ReadInt32();
         int stringBufferSize = reader.ReadInt32();
         Nodes = new TypeTreeNode[nodesCount];
         for (int i = 0; i < nodesCount; i++)
         {
             TypeTreeNode node = new TypeTreeNode();
             node.Read(reader);
             Nodes[i] = node;
         }
         StringBuffer = new byte[stringBufferSize];
         reader.Read(StringBuffer, 0, StringBuffer.Length);
     }
     else
     {
         List <TypeTreeNode> nodes = new List <TypeTreeNode>();
         ReadTreeNode(reader, nodes, 0);
         Nodes = nodes.ToArray();
     }
 }
Exemplo n.º 5
0
        public void Read(SerializedFileReader reader)
        {
            if (IsRead5Format(reader.Generation))
            {
                int nodesCount = reader.ReadInt32();
                if (nodesCount < 0)
                {
                    throw new Exception($"Invalid type tree's node count {nodesCount}");
                }

                int stringSize = reader.ReadInt32();
                if (stringSize < 0)
                {
                    throw new Exception($"Invalid type tree's string size {stringSize}");
                }

                TypeTreeNode[] nodes          = new TypeTreeNode[nodesCount];
                long           stringPosition = reader.BaseStream.Position + nodesCount * TypeTreeNode.GetNodeSize(reader.Generation);
                for (int i = 0; i < nodesCount; i++)
                {
                    TypeTreeNode node = new TypeTreeNode();
                    node.Read(reader, stringPosition);
                    nodes[i] = node;
                }
                Nodes = nodes;
                reader.BaseStream.Position += stringSize;
            }
            else
            {
                List <TypeTreeNode> nodes = new List <TypeTreeNode>();
                ReadTreeNode(reader, nodes, 0);
                Nodes = nodes.ToArray();
            }
        }