internal static ByteBuffer ReadBinaryBuffer(ByteBuffer buffer)
{
byte formatCode = Encoder.ReadFormatCode(buffer);
if (formatCode == FormatCode.Null)
{
return null;
}
int count;
if (formatCode == FormatCode.Binary8)
{
count = AmqpBitConverter.ReadUByte(buffer);
}
else if (formatCode == FormatCode.Binary32)
{
count = (int)AmqpBitConverter.ReadUInt(buffer);
}
else
{
throw InvalidFormatCodeException(formatCode, buffer.Offset);
}
buffer.Validate(false, count);
ByteBuffer result = new ByteBuffer(buffer.Buffer, buffer.Offset, count, count);
buffer.Complete(count);
return result;
}
}