public final int serialize(int offset, byte[] data) {int dataSize = getDataSize();int recSize = 4 + dataSize;try (LittleEndianByteArrayOutputStream out =new LittleEndianByteArrayOutputStream(data, offset, recSize)) {out.writeShort(getSid());out.writeShort(dataSize);serialize(out);if (out.getWriteIndex() - offset != recSize) {throw new IllegalStateException("Error in serialization of (" + getClass().getName() + "): "+ "Incorrect number of bytes written - expected " + recSize + " but got "+ (out.getWriteIndex() - offset));}} catch (IOException ioe) {throw new IllegalStateException(ioe);}return recSize;}
public override int Serialize(int offset, byte[] data){int dataSize = DataSize;int recSize = 4 + dataSize;LittleEndianByteArrayOutputStream out1 = new LittleEndianByteArrayOutputStream(data, offset, recSize);out1.WriteShort(this.Sid);out1.WriteShort(dataSize);Serialize(out1);if (out1.WriteIndex - offset != recSize){throw new InvalidOperationException("Error in serialization of (" + this.GetType().Name + "): "+ "Incorrect number of bytes written - expected "+ recSize + " but got " + (out1.WriteIndex - offset));}return recSize;}