Beispiel #1
0
        private int readDataByteBuffer(ByteBufferReader reader, List <object> data)
        {
            Assert.IsNotNull(reader);
            Assert.IsNotNull(data);
            int count = 0;

            while (reader.Position < reader.Buffer.Count)
            {
                int    index = (int)reader.ReadVarint32();
                object value = null;
                switch (index)
                {
                case 0:
                    value = reader.ReadBool();
                    break;

                case 1:
                    value = reader.ReadByte();
                    break;

                case 2:
                    value = reader.ReadUint16();
                    break;

                case 3:
                    value = reader.ReadUint32();
                    break;

                case 4:
                    value = reader.ReadUint64();
                    break;

                case 5:
                    value = reader.ReadInt16();
                    break;

                case 6:
                    value = reader.ReadInt32();
                    break;

                case 7:
                    value = reader.ReadInt64();
                    break;

                case 8:
                    value = reader.ReadVarint32();
                    break;

                case 9:
                    value = reader.ReadVarint64();
                    break;

                case 10:
                    value = reader.ReadSVarint32();
                    break;

                case 11:
                    value = reader.ReadSVarint64();
                    break;

                case 12:
                    value = reader.ReadFloat();
                    break;

                case 13:
                    value = reader.ReadDouble();
                    break;

                case 14:
                    value = reader.ReadString();
                    break;

                case 15: {
                    int length = (int)reader.ReadVarint32();
                    value = new byte[length];
                    reader.ReadBuffer((byte[])value, 0, length);
                }
                break;

                case 16: {
                    int size = (int)reader.ReadVarint32();
                    reader.Skip(size);
                    value = size;
                }
                break;

                default:
                    Assert.Fail();
                    break;
                }

                Assert.AreEqual(value, data[index], "index: " + index);
                count++;
            }

            return(count);
        }