public byte[] Serialize()
{
// 0 indicates start index
int index = 0;
byte[] serializedBuffer = new byte[this.Size()];
serializedBuffer[index++] = this.RopId;
serializedBuffer[index++] = this.LogonId;
serializedBuffer[index++] = this.InputHandleIndex;
Array.Copy(BitConverter.GetBytes((uint)this.SourceFolderIdSize), 0, serializedBuffer, index, sizeof(uint));
index += sizeof(uint);
if (this.SourceFolderIdSize > 0)
{
Array.Copy(this.SourceFolderId, 0, serializedBuffer, index, this.SourceFolderIdSize);
index += (int)this.SourceFolderIdSize;
}
Array.Copy(BitConverter.GetBytes((uint)this.SourceMessageIdSize), 0, serializedBuffer, index, sizeof(uint));
index += sizeof(uint);
if (this.SourceMessageIdSize > 0)
{
Array.Copy(this.SourceMessageId, 0, serializedBuffer, index, this.SourceMessageIdSize);
index += (int)this.SourceMessageIdSize;
}
Array.Copy(BitConverter.GetBytes((uint)this.PredecessorChangeListSize), 0, serializedBuffer, index, sizeof(uint));
index += sizeof(uint);
if (this.PredecessorChangeListSize > 0)
{
Array.Copy(this.PredecessorChangeList, 0, serializedBuffer, index, this.PredecessorChangeListSize);
index += (int)this.PredecessorChangeListSize;
}
Array.Copy(BitConverter.GetBytes((uint)this.DestinationMessageIdSize), 0, serializedBuffer, index, sizeof(uint));
index += sizeof(uint);
if (this.DestinationMessageIdSize > 0)
{
Array.Copy(this.DestinationMessageId, 0, serializedBuffer, index, this.DestinationMessageIdSize);
index += (int)this.DestinationMessageIdSize;
}
Array.Copy(BitConverter.GetBytes((uint)this.ChangeNumberSize), 0, serializedBuffer, index, sizeof(uint));
index += sizeof(uint);
if (this.ChangeNumberSize > 0)
{
Array.Copy(this.ChangeNumber, 0, serializedBuffer, index, this.ChangeNumberSize);
index += (int)this.ChangeNumberSize;
}
return serializedBuffer;
}