in src/AmqpMessage.cs [920:967]
protected override void EncodeBody(ByteBuffer buffer)
{
int pos = buffer.WritePos;
buffer.ValidateWrite(8);
buffer.Append(8);
int length = 0;
long streamPos = this.bodyStream.CanSeek ? this.bodyStream.Position : -1;
try
{
while (true)
{
buffer.ValidateWrite(512);
int size = this.bodyStream.Read(buffer.Buffer, buffer.WritePos, 512);
if (size == 0)
{
break;
}
buffer.Append(size);
length += size;
}
}
finally
{
if (this.bodyStream.CanSeek)
{
this.bodyStream.Position = streamPos;
}
}
buffer.Buffer[pos] = FormatCode.Described;
buffer.Buffer[pos + 1] = FormatCode.SmallULong;
buffer.Buffer[pos + 2] = (byte)Data.Code;
buffer.Buffer[pos + 3] = FormatCode.Binary32;
AmqpBitConverter.WriteUInt(buffer.Buffer, pos + 4, (uint)length);
this.bodyOffset = pos;
this.bodyLength = buffer.WritePos - pos;
this.dataList = new Data[]
{
new Data()
{
Segment = new ArraySegment<byte>(buffer.Buffer, pos, length),
Offset = pos,
Length = length
}
};
}