in src/Proton/Codec/Decoders/Transport/DispositionTypeDecoder.cs [157:222]
private static Disposition ReadDisposition(Stream stream, IStreamDecoderState state, IListTypeDecoder listDecoder)
{
Disposition result = new();
_ = listDecoder.ReadSize(stream, state);
int count = listDecoder.ReadCount(stream, state);
if (count < MinDispositionListEntries)
{
throw new DecodeException(ErrorForMissingRequiredFields(count));
}
if (count > MaxDispositionListEntries)
{
throw new DecodeException("To many entries in Disposition 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 < MinDispositionListEntries)
{
throw new DecodeException(ErrorForMissingRequiredFields(index));
}
continue;
}
else
{
stream.Seek(-1, SeekOrigin.Current);
}
}
switch (index)
{
case 0:
result.Role = RoleExtension.Lookup(state.Decoder.ReadBoolean(stream, state) ?? false);
break;
case 1:
result.First = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
break;
case 2:
result.Last = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
break;
case 3:
result.Settled = state.Decoder.ReadBoolean(stream, state) ?? false;
break;
case 4:
result.State = state.Decoder.ReadObject<IDeliveryState>(stream, state);
break;
case 5:
result.Batchable = state.Decoder.ReadBoolean(stream, state) ?? false;
break;
}
}
return result;
}