/// <summary> /// Deserialize fields in this class from a stream. /// </summary> /// <param name="stream">Stream contains a serialized instance of this class.</param> /// <param name="size">The number of bytes can read if -1, no limitation.</param> /// <returns>Bytes have been read from the stream.</returns> public override int Deserialize(Stream stream, int size) { int bytesRead = 0; this.version = StreamHelper.ReadUInt16(stream); bytesRead += 2; if (size >= 0 && bytesRead > size) { AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead); } this.padding1 = StreamHelper.ReadUInt16(stream); bytesRead += 2; if (size >= 0 && bytesRead > size) { AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead); } this.faiMessageCount = StreamHelper.ReadUInt32(stream); bytesRead += 4; if (size >= 0 && bytesRead > size) { AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead); } this.faiMessageTotalSize = StreamHelper.ReadUInt64(stream); bytesRead += 8; if (size >= 0 && bytesRead > size) { AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead); } this.normalMessageCount = StreamHelper.ReadUInt32(stream); bytesRead += 4; if (size >= 0 && bytesRead > size) { AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead); } this.padding2 = StreamHelper.ReadUInt32(stream); bytesRead += 4; if (size >= 0 && bytesRead > size) { AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead); } this.normalMessageTotalSize = StreamHelper.ReadUInt64(stream); bytesRead += 8; if (size >= 0 && bytesRead > size) { AdapterHelper.Site.Assert.Fail("The bytes length to read is larger than stream size, the stream size is {0} and the bytes to read is {1}.", size, bytesRead); } return(bytesRead); }