public static ReadMap ( System.ByteBuffer buffer, byte formatCode ) : Amqp.Types.Map | ||
buffer | System.ByteBuffer | The buffer to read. |
formatCode | byte | The format code of the value. |
return | Amqp.Types.Map |
public static Map ReadMap(ByteBuffer buffer, byte formatCode)
{
if (formatCode == FormatCode.Null)
{
return null;
}
int size;
int count;
if (formatCode == FormatCode.Map8)
{
size = AmqpBitConverter.ReadUByte(buffer);
count = AmqpBitConverter.ReadUByte(buffer);
}
else if (formatCode == FormatCode.Map32)
{
size = (int)AmqpBitConverter.ReadUInt(buffer);
count = (int)AmqpBitConverter.ReadUInt(buffer);
}
else
{
throw InvalidFormatCodeException(formatCode, buffer.Offset);
}
if (count % 2 > 0)
{
throw InvalidMapCountException(count);
}
Map value = new Map();
for (int i = 0; i < count; i += 2)
{
value.Add(ReadObject(buffer), ReadObject(buffer));
}
return value;
}
internal override void DecodeValue(ByteBuffer buffer) { this.map = Encoder.ReadMap(buffer, Encoder.ReadFormatCode(buffer)); }