private void writeDataByteBuffer(ByteBufferWriter writer, int index, object data) { Assert.IsNotNull(writer); Assert.IsNotNull(data); writer.WriteVarint32((uint)index); switch (index) { case 0: writer.WriteBool((bool)data); break; case 1: writer.WriteByte((byte)data); break; case 2: writer.WriteUint16((ushort)data); break; case 3: writer.WriteUint32((uint)data); break; case 4: writer.WriteUint64((ulong)data); break; case 5: writer.WriteInt16((short)data); break; case 6: writer.WriteInt32((int)data); break; case 7: writer.WriteInt64((long)data); break; case 8: writer.WriteVarint32((uint)data); break; case 9: writer.WriteVarint64((ulong)data); break; case 10: writer.WriteSVarint32((int)data); break; case 11: writer.WriteSVarint64((long)data); break; case 12: writer.WriteFloat((float)data); break; case 13: writer.WriteDouble((double)data); break; case 14: writer.WriteString((string)data); break; case 15: { var buffer = (byte[])data; writer.WriteVarint32((uint)buffer.Length); writer.WriteBuffer(buffer, 0, buffer.Length); } break; case 16: { writer.WriteVarint32((uint)(int)data); writer.Skip((int)data); } break; default: Assert.Fail(); break; } }