public void Serialize(MemoryEndianBinaryWriter writer) { FieldMark fm = new FieldMark(1); fm.Mark(byteArray != null && byteArray.Length > 0); fm.Mark(shortArray != null && shortArray.Length > 0); fm.Mark(intArray != null && intArray.Length > 0); fm.Mark(longArray != null && longArray.Length > 0); fm.Mark(floatArray != null && floatArray.Length > 0); fm.Mark(doubleArray != null && doubleArray.Length > 0); writer.Write(fm.getData()); if (fm.IsMarked(0)) { SerializationUtil.WriteVariableLength(writer, byteArray.Length); for (int i = 0; i < byteArray.Length; i++) { writer.WriteInt8(byteArray[i]); } } if (fm.IsMarked(1)) { SerializationUtil.WriteVariableLength(writer, shortArray.Length); for (int i = 0; i < shortArray.Length; i++) { writer.WriteInt16(shortArray[i]); } } if (fm.IsMarked(2)) { SerializationUtil.WriteVariableLength(writer, intArray.Length); for (int i = 0; i < intArray.Length; i++) { writer.WriteInt32(intArray[i]); } } if (fm.IsMarked(3)) { SerializationUtil.WriteVariableLength(writer, longArray.Length); for (int i = 0; i < longArray.Length; i++) { writer.WriteInt64(longArray[i]); } } if (fm.IsMarked(4)) { SerializationUtil.WriteVariableLength(writer, floatArray.Length); for (int i = 0; i < floatArray.Length; i++) { writer.WriteSingle(floatArray[i]); } } if (fm.IsMarked(5)) { SerializationUtil.WriteVariableLength(writer, doubleArray.Length); for (int i = 0; i < doubleArray.Length; i++) { writer.WriteDouble(doubleArray[i]); } } }