private static Transfer ReadTransfer()

in src/Proton/Codec/Decoders/Transport/TransferTypeDecoder.cs [172:252]


      private static Transfer ReadTransfer(Stream stream, IStreamDecoderState state, IListTypeDecoder listDecoder)
      {
         Transfer result = new();

         _ = listDecoder.ReadSize(stream, state);
         int count = listDecoder.ReadCount(stream, state);

         if (count < MinTransferListEntries)
         {
            throw new DecodeException("The handle field cannot be omitted from the Transfer");
         }

         if (count > MaxTransferListEntries)
         {
            throw new DecodeException("To many entries in Transfer 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)
               {
                  if (index == 0)
                  {
                     throw new DecodeException("The handle field cannot be omitted from the Transfer");
                  }

                  continue;
               }
               else
               {
                  stream.Seek(-1, SeekOrigin.Current);
               }
            }

            switch (index)
            {
               case 0:
                  result.Handle = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
                  break;
               case 1:
                  result.DeliveryId = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
                  break;
               case 2:
                  result.DeliveryTag = state.Decoder.ReadDeliveryTag(stream, state);
                  break;
               case 3:
                  result.MessageFormat = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
                  break;
               case 4:
                  result.Settled = state.Decoder.ReadBoolean(stream, state) ?? false;
                  break;
               case 5:
                  result.More = state.Decoder.ReadBoolean(stream, state) ?? false;
                  break;
               case 6:
                  byte rcvSettleMode = state.Decoder.ReadUnsignedByte(stream, state) ?? 0;
                  result.ReceiverSettleMode = ReceiverSettleModeExtension.Lookup(rcvSettleMode);
                  break;
               case 7:
                  result.DeliveryState = state.Decoder.ReadObject<IDeliveryState>(stream, state);
                  break;
               case 8:
                  result.Resume = state.Decoder.ReadBoolean(stream, state) ?? false;
                  break;
               case 9:
                  result.Aborted = state.Decoder.ReadBoolean(stream, state) ?? false;
                  break;
               case 10:
                  result.Batchable = state.Decoder.ReadBoolean(stream, state) ?? false;
                  break;
            }
         }

         return result;
      }