public static byte[] ReadBinary(ByteBuffer buffer, byte formatCode)
{
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);
byte[] value = new byte[count];
Array.Copy(buffer.Buffer, buffer.Offset, value, 0, count);
buffer.Complete(count);
return value;
}