/// <summary>Writes a specified value as JSON.</summary> /// <param name="writer">The writer to write to.</param> /// <param name="value">The value to convert to JSON.</param> /// <param name="options">An object that specifies serialization options to use.</param> public override void Write( Utf8JsonWriter writer, CosmosPagedList <T> value, JsonSerializerOptions options) { writer.WriteStartObject(); writer.WriteNumber(nameof(PagedList <T> .PageNumber), value.PageNumber); writer.WriteNumber(nameof(PagedList <T> .PageSize), value.PageSize); writer.WriteString(nameof(CosmosPagedList <T> .ContinuationToken), value.ContinuationToken); writer.WritePropertyName("List"); JsonSerializer.Serialize(writer, value.ToList(), options); writer.WriteEndObject(); }
/// <summary> /// Returns a <see cref="CosmosPagedList{T}"/> wrapper for the current <see /// cref="FeedIterator{T}"/>. /// </summary> /// <typeparam name="T">The type of items in the collection.</typeparam> /// <param name="iterator">The current <see cref="FeedIterator{T}"/>.</param> /// <param name="pageNumber">The current page number.</param> /// <param name="pageSize">The page size.</param> /// <returns>A <see cref="CosmosPagedList{T}"/> containing the items in the current /// collection.</returns> public static Task <CosmosPagedList <T> > AsCosmosPagedListAsync <T>( this FeedIterator <T>?iterator, long pageNumber, long pageSize) => CosmosPagedList <T> .FromFeedIteratorAsync(iterator, pageNumber, pageSize);