Example #1
0
        /// <summary>
        /// Read the event sequence number from the <see cref="Utf8JsonStreamReader"/>.
        /// </summary>
        /// <param name="streamReader">The stream reader from which to read the event sequence number.</param>
        /// <returns>The event sequence number.</returns>
        public static long ReadEventSequenceNumber(ref Utf8JsonStreamReader streamReader)
        {
            streamReader.Read();
            if (streamReader.TokenType != JsonTokenType.PropertyName || !streamReader.Match(EventSequenceNumberPropertyNameString))
            {
                throw new JsonException($"Expected to find the {EventSequenceNumberPropertyNameString} property.");
            }

            streamReader.Read();
            if (streamReader.TokenType != JsonTokenType.Number)
            {
                throw new JsonException($"Expected the {EventSequenceNumberPropertyNameString} property to be a number.");
            }

            return(streamReader.GetInt64());
        }