// Token: 0x06000033 RID: 51 RVA: 0x00002D68 File Offset: 0x00000F68 private static int GetNodeCount(PNode node) { if (node == null) { throw new ArgumentNullException("node"); } ArrayNode arrayNode = node as ArrayNode; if (arrayNode != null) { int num = 1; foreach (PNode node2 in arrayNode) { num += BinaryFormatWriter.GetNodeCount(node2); } return(num); } DictionaryNode dictionaryNode = node as DictionaryNode; if (dictionaryNode != null) { int num2 = 1; foreach (PNode node3 in dictionaryNode.Values) { num2 += BinaryFormatWriter.GetNodeCount(node3); } num2 += dictionaryNode.Keys.Count; return(num2); } return(1); }
// Token: 0x06000031 RID: 49 RVA: 0x00002BF0 File Offset: 0x00000DF0 private void WriteInternal(Stream stream, byte nodeIndexSize, List <int> offsets, ArrayNode array) { byte[] array2 = new byte[(int)nodeIndexSize * array.Count]; long position = stream.Position; stream.Write(array2, 0, array2.Length); for (int i = 0; i < array.Count; i++) { BinaryFormatWriter.FormatIdx(this.WriteInternal(stream, nodeIndexSize, offsets, array[i]), nodeIndexSize).CopyTo(array2, (int)nodeIndexSize * i); } stream.Seek(position, SeekOrigin.Begin); stream.Write(array2, 0, array2.Length); stream.Seek(0L, SeekOrigin.End); }
// Token: 0x06000032 RID: 50 RVA: 0x00002C70 File Offset: 0x00000E70 private void WriteInternal(Stream stream, byte nodeIndexSize, List <int> offsets, DictionaryNode dictionary) { byte[] array = new byte[(int)nodeIndexSize * dictionary.Count]; byte[] array2 = new byte[(int)nodeIndexSize * dictionary.Count]; long position = stream.Position; stream.Write(array, 0, array.Length); stream.Write(array2, 0, array2.Length); KeyValuePair <string, PNode>[] array3 = dictionary.ToArray <KeyValuePair <string, PNode> >(); for (int i = 0; i < dictionary.Count; i++) { BinaryFormatWriter.FormatIdx(this.WriteInternal(stream, nodeIndexSize, offsets, NodeFactory.CreateKeyElement(array3[i].Key)), nodeIndexSize).CopyTo(array, (int)nodeIndexSize * i); } for (int j = 0; j < dictionary.Count; j++) { BinaryFormatWriter.FormatIdx(this.WriteInternal(stream, nodeIndexSize, offsets, array3[j].Value), nodeIndexSize).CopyTo(array2, (int)nodeIndexSize * j); } stream.Seek(position, SeekOrigin.Begin); stream.Write(array, 0, array.Length); stream.Write(array2, 0, array2.Length); stream.Seek(0L, SeekOrigin.End); }
// Token: 0x0600002F RID: 47 RVA: 0x00002920 File Offset: 0x00000B20 public void Write(Stream stream, PNode node) { stream.Write(BinaryFormatWriter._header, 0, BinaryFormatWriter._header.Length); List <int> list = new List <int>(); int num = BinaryFormatWriter.GetNodeCount(node); byte b; if (num <= 255) { b = 1; } else if (num <= 32767) { b = 2; } else { b = 4; } int host = this.WriteInternal(stream, b, list, node); num = list.Count; int num2 = (int)stream.Position; byte b2; if (num2 <= 255) { b2 = 1; } else if (num2 <= 32767) { b2 = 2; } else { b2 = 4; } for (int i = 0; i < list.Count; i++) { byte[] array = null; switch (b2) { case 1: array = new byte[] { (byte)list[i] }; break; case 2: array = BitConverter.GetBytes(EndianConverter.HostToNetworkOrder((short)list[i])); break; case 4: array = BitConverter.GetBytes(EndianConverter.HostToNetworkOrder(list[i])); break; } stream.Write(array, 0, array.Length); } byte[] array2 = new byte[32]; array2[6] = b2; array2[7] = b; BitConverter.GetBytes(EndianConverter.HostToNetworkOrder(num)).CopyTo(array2, 12); BitConverter.GetBytes(EndianConverter.HostToNetworkOrder(host)).CopyTo(array2, 20); BitConverter.GetBytes(EndianConverter.HostToNetworkOrder(num2)).CopyTo(array2, 28); stream.Write(array2, 0, array2.Length); }