in src/Proton/Codec/Decoders/Transport/BeginTypeDecoder.cs [164:235]
private static Begin ReadBegin(Stream stream, IStreamDecoderState state, IListTypeDecoder listDecoder)
{
Begin result = new();
_ = listDecoder.ReadSize(stream, state);
int count = listDecoder.ReadCount(stream, state);
if (count < MinBeginListEntries)
{
throw new DecodeException(ErrorForMissingRequiredFields(count));
}
if (count > MaxBeginListEntries)
{
throw new DecodeException("To many entries in Begin list encoding: " + count);
}
for (int index = 0; index < count; ++index)
{
// Peek ahead and see if there is a null in the next slot, if so we don't call
// the setter for that entry to ensure the returned type reflects the encoded
// state in the modification entry.
if (stream.CanSeek)
{
bool nullValue = stream.ReadByte() == (byte)EncodingCodes.Null;
if (nullValue)
{
// Ensure mandatory fields are set
if (index < MinBeginListEntries)
{
throw new DecodeException(ErrorForMissingRequiredFields(index));
}
continue;
}
else
{
stream.Seek(-1, SeekOrigin.Current);
}
}
switch (index)
{
case 0:
result.RemoteChannel = state.Decoder.ReadUnsignedShort(stream, state) ?? 0;
break;
case 1:
result.NextOutgoingId = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
break;
case 2:
result.IncomingWindow = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
break;
case 3:
result.OutgoingWindow = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
break;
case 4:
result.HandleMax = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
break;
case 5:
result.OfferedCapabilities = state.Decoder.ReadMultiple<Symbol>(stream, state);
break;
case 6:
result.DesiredCapabilities = state.Decoder.ReadMultiple<Symbol>(stream, state);
break;
case 7:
result.Properties = state.Decoder.ReadMap<Symbol, object>(stream, state);
break;
}
}
return result;
}