Skip to content

Commit

Permalink
X.PagedList: PagedListExtensions: Add missing variant for IEnumerable
Browse files Browse the repository at this point in the history
This has an async-over-sync implementation, but no native sync one. Add it.
  • Loading branch information
adschmu committed Jul 10, 2024
1 parent 676aaa8 commit 6a79a71
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/X.PagedList/PagedListExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,32 @@ public static IPagedList<T> ToPagedList<T>(this IEnumerable<T> superset, int pag
return new PagedList<T>(superset, pageNumber, pageSize);
}

/// <summary>
/// Creates a subset of this collection of objects that can be individually accessed by index and containing
/// metadata about the collection of objects the subset was created from.
/// </summary>
/// <typeparam name="T">The type of object the collection should contain.</typeparam>
/// <param name="superset">
/// The collection of objects to be divided into subsets. If the collection
/// implements <see cref="IEnumerable{T}"/>, it will be treated as such.
/// </param>
/// <param name="pageNumber">The one-based index of the subset of objects to be contained by this instance.</param>
/// <param name="pageSize">The maximum size of any individual subset.</param>
/// <param name="totalSetCount">The total size of set</param>
/// <returns>
/// A subset of this collection of objects that can be individually accessed by index and containing metadata
/// about the collection of objects the subset was created from.
/// </returns>
public static IPagedList<T> ToPagedList<T>(this IEnumerable<T> superset, int pageNumber, int pageSize, int? totalSetCount)
{
if (superset == null)
{
throw new ArgumentNullException(nameof(superset));
}

return ToPagedList(superset.AsQueryable(), pageNumber, pageSize, totalSetCount);
}

/// <summary>
/// Creates a subset of this collection of objects that can be individually accessed by index and containing
/// metadata about the collection of objects the subset was created from.
Expand Down

0 comments on commit 6a79a71

Please sign in to comment.