public virtual byte[] Serialize()
{
int length = this.Size();
byte[] resultBytes = new byte[length];
if (this.isVariableSize)
{
// Fill 2 bytes with length
resultBytes[0] = (byte)((ushort)this.value.Length & 0x00FF);
resultBytes[1] = (byte)(((ushort)this.value.Length & 0xFF00) >> 8);
}
Array.Copy(this.value, 0, resultBytes, this.isVariableSize == false ? 0 : 2, this.value.Length);
return resultBytes;
}