Exemplo n.º 1
0
 public static void Read(ref Utf8JsonStreamReader reader)
 {
     if (!reader.Read())
     {
         throw new InvalidDataException("Unexpected end of stream");
     }
 }
Exemplo n.º 2
0
        public static void ReadToken(ref Utf8JsonStreamReader reader, JsonTokenType token)
        {
            Read(ref reader);

            if (reader.TokenType != token)
            {
                throw new InvalidDataException($"Unexpected token at position {reader.Position}: expected {token} but got {reader.TokenType}");
            }
        }
Exemplo n.º 3
0
 public static string ReadString(ref Utf8JsonStreamReader reader)
 {
     ReadToken(ref reader, JsonTokenType.String);
     return(reader.GetString());
 }
Exemplo n.º 4
0
 public static uint ReadUInt32(ref Utf8JsonStreamReader reader)
 {
     ReadToken(ref reader, JsonTokenType.Number);
     return(reader.GetUInt32());
 }