private static Open ReadOpen()

in src/Proton/Codec/Decoders/Transport/OpenTypeDecoder.cs [168:244]


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

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

         if (count < MinOpenListEntries)
         {
            throw new DecodeException("The container-id field cannot be omitted from the Open");
         }

         if (count > MaxOpenListEntries)
         {
            throw new DecodeException("To many entries in Open 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 container-id field cannot be omitted from the Open");
                  }

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

            switch (index)
            {
               case 0:
                  result.ContainerId = state.Decoder.ReadString(stream, state);
                  break;
               case 1:
                  result.Hostname = state.Decoder.ReadString(stream, state);
                  break;
               case 2:
                  result.MaxFrameSize = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
                  break;
               case 3:
                  result.ChannelMax = state.Decoder.ReadUnsignedShort(stream, state) ?? 0;
                  break;
               case 4:
                  result.IdleTimeout = state.Decoder.ReadUnsignedInteger(stream, state) ?? 0;
                  break;
               case 5:
                  result.OutgoingLocales = state.Decoder.ReadMultiple<Symbol>(stream, state);
                  break;
               case 6:
                  result.IncomingLocales = state.Decoder.ReadMultiple<Symbol>(stream, state);
                  break;
               case 7:
                  result.OfferedCapabilities = state.Decoder.ReadMultiple<Symbol>(stream, state);
                  break;
               case 8:
                  result.DesiredCapabilities = state.Decoder.ReadMultiple<Symbol>(stream, state);
                  break;
               case 9:
                  result.Properties = state.Decoder.ReadMap<Symbol, object>(stream, state);
                  break;
            }
         }

         return result;
      }