public static Array ReadArray(ByteBuffer buffer, byte formatCode)
{
if (formatCode == FormatCode.Null)
{
return null;
}
int size;
int count;
if (formatCode == FormatCode.Array8)
{
size = AmqpBitConverter.ReadUByte(buffer);
count = AmqpBitConverter.ReadUByte(buffer);
}
else if (formatCode == FormatCode.Array32)
{
size = (int)AmqpBitConverter.ReadUInt(buffer);
count = (int)AmqpBitConverter.ReadUInt(buffer);
}
else
{
throw InvalidFormatCodeException(formatCode, buffer.Offset);
}
formatCode = Encoder.ReadFormatCode(buffer);
Serializer codec = GetSerializer(formatCode);
if (codec == null)
{
throw InvalidFormatCodeException(formatCode, buffer.Offset);
}
Array value = Array.CreateInstance(codec.Type, count);
IList list = value;
for (int i = 0; i < count; ++i)
{
list[i] = codec.Decoder(buffer, formatCode);
}
return value;
}