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;
serializedBuffer[index++] = this.OutputHandleIndex;
serializedBuffer[index++] = this.SynchronizationType;
serializedBuffer[index++] = this.SendOptions;
Array.Copy(BitConverter.GetBytes((ushort)this.SynchronizationFlags), 0, serializedBuffer, index, sizeof(ushort));
index += sizeof(ushort);
Array.Copy(BitConverter.GetBytes((ushort)this.RestrictionDataSize), 0, serializedBuffer, index, sizeof(ushort));
index += sizeof(ushort);
if (this.RestrictionDataSize > 0)
{
Array.Copy(this.RestrictionData, 0, serializedBuffer, index, this.RestrictionDataSize);
index += this.RestrictionDataSize;
}
Array.Copy(BitConverter.GetBytes((uint)this.SynchronizationExtraFlags), 0, serializedBuffer, index, sizeof(uint));
index += sizeof(uint);
Array.Copy(BitConverter.GetBytes((ushort)this.PropertyTagCount), 0, serializedBuffer, index, sizeof(ushort));
index += sizeof(ushort);
for (int i = 0; i < this.PropertyTagCount; i++)
{
Array.Copy(this.PropertyTags[i].Serialize(), 0, serializedBuffer, index, this.PropertyTags[i].Size());
index += this.PropertyTags[i].Size();
}
return serializedBuffer;
}