private Info ReadInfo() { reader.BeginReadMessage(); var result = new Info(); while (reader.State == ProtobufReaderState.Field) { switch (reader.FieldNumber) { case 1: result.Version = reader.ReadInt32(); break; case 2: result.Timestamp = reader.ReadInt32(); break; case 3: result.ChangeSet = reader.ReadInt64(); break; case 4: result.UserId = reader.ReadInt32(); break; case 5: result.UserStringId = reader.ReadInt32(); break; case 6: result.Visible = reader.ReadInt64() != 0; break; default: reader.Skip(); break; } } reader.EndReadMessage(); return(result); }
public void TestInt32Read() { var bytes = new byte[] { 0x08, 0x96, 0x01 }; using (var stream = new MemoryStream(bytes)) { var reader = new ProtobufReader(stream, stream.Length); reader.BeginReadMessage(stream.Length); reader.FieldNumber.Should().Be(1); reader.FieldType.Should().Be(FieldTypes.VarInt); var value = reader.ReadInt32(); value.Should().Be(150); } }