/// <summary> /// Read the ToDoItemId from the stream and consume to the end of the payload. /// </summary> /// <param name="streamReader">The reader from which to read the id.</param> /// <returns>The ID read from the payload.</returns> public static Guid ReadToDoItemId(ref Utf8JsonStreamReader streamReader) { if (streamReader.TokenType != JsonTokenType.StartObject) { throw new JsonException("Expected to be at the start of the event payload."); } // Read the ID streamReader.Read(); if (streamReader.TokenType != JsonTokenType.PropertyName || !streamReader.Match(IdPropertyString)) { throw new JsonException($"Expected to find the {IdPropertyString}."); } streamReader.Read(); if (streamReader.TokenType != JsonTokenType.String) { throw new JsonException("Expected to find a string-encoded GUID property."); } Guid id = streamReader.GetGuid(); // Read to the end of the object streamReader.Read(); if (streamReader.TokenType != JsonTokenType.EndObject) { throw new JsonException("Expected to be at the end of the event payload."); } return(id); }