in src/Serialization/SerializableType.cs [537:604]
protected override void Initialize(ByteBuffer buffer, FormatCode formatCode,
out int size, out int count, out int encodeWidth, out Collection effectiveType)
{
if (formatCode != FormatCode.Described)
{
throw new AmqpException(AmqpErrorCode.InvalidField, AmqpResources.GetString(AmqpResources.AmqpInvalidFormatCode, formatCode, buffer.Offset));
}
effectiveType = null;
formatCode = AmqpEncoding.ReadFormatCode(buffer);
ulong? code = null;
AmqpSymbol symbol = default(AmqpSymbol);
if (formatCode == FormatCode.ULong0)
{
code = 0;
}
else if (formatCode == FormatCode.ULong || formatCode == FormatCode.SmallULong)
{
code = ULongEncoding.Decode(buffer, formatCode);
}
else if (formatCode == FormatCode.Symbol8 || formatCode == FormatCode.Symbol32)
{
symbol = SymbolEncoding.Decode(buffer, formatCode);
}
if (this.AreEqual(this.descriptorCode, this.descriptorName, code, symbol))
{
effectiveType = this;
}
else if (this.knownTypes != null)
{
for (int i = 0; i < this.knownTypes.Count; ++i)
{
Composite knownType = (Composite)this.serializer.GetType(this.knownTypes[i]);
if (this.AreEqual(knownType.descriptorCode, knownType.descriptorName, code, symbol))
{
effectiveType = knownType;
break;
}
}
}
if (effectiveType == null)
{
throw new SerializationException(AmqpResources.GetString(AmqpResources.AmqpUnknownDescriptor, code ?? (object)symbol.Value, this.type.Name));
}
formatCode = AmqpEncoding.ReadFormatCode(buffer);
if (this.Code == FormatCode.List32)
{
if (formatCode == FormatCode.List0)
{
size = count = encodeWidth = 0;
}
else
{
encodeWidth = formatCode == FormatCode.List8 ? FixedWidth.UByte : FixedWidth.UInt;
AmqpEncoding.ReadSizeAndCount(buffer, formatCode, FormatCode.List8,
FormatCode.List32, out size, out count);
}
}
else
{
encodeWidth = formatCode == FormatCode.Map8 ? FixedWidth.UByte : FixedWidth.UInt;
AmqpEncoding.ReadSizeAndCount(buffer, formatCode, FormatCode.Map8,
FormatCode.Map32, out size, out count);
}
}