diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index 747d9b0e..ef369162 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -1,18 +1,22 @@ using System; using System.Collections; using System.Collections.Generic; +using JetBrains.Annotations; namespace X.PagedList { /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. /// /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. /// /// The type of object the collection should contain. /// /// + [PublicAPI] public abstract class BasePagedList : PagedListMetaData, IPagedList { protected readonly List Subset = new List(); @@ -25,7 +29,8 @@ protected internal BasePagedList() } /// - /// Initializes a new instance of a type deriving from and sets properties needed to calculate position and size data on the subset and superset. + /// Initializes a new instance of a type deriving from and sets properties + /// needed to calculate position and size data on the subset and superset. /// /// The one-based index of the subset of objects contained by this instance. /// The maximum size of any individual subset. @@ -56,7 +61,7 @@ protected internal BasePagedList(int pageNumber, int pageSize, int totalItemCoun ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) : 0; - bool pageNumberIsGood = PageCount > 0 && PageNumber <= PageCount; + var pageNumberIsGood = PageCount > 0 && PageNumber <= PageCount; HasPreviousPage = pageNumberIsGood && PageNumber > 1; HasNextPage = pageNumberIsGood && PageNumber < PageCount; diff --git a/src/X.PagedList/IPagedList.cs b/src/X.PagedList/IPagedList.cs index ac46fea2..e77479f6 100644 --- a/src/X.PagedList/IPagedList.cs +++ b/src/X.PagedList/IPagedList.cs @@ -1,121 +1,128 @@ using System.Collections.Generic; +using JetBrains.Annotations; namespace X.PagedList { - /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. - /// - /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. - /// - /// The type of object the collection should contain. - /// - public interface IPagedList : IPagedList, IReadOnlyList, IEnumerable - { - /// - /// Gets the element at the specified index. - /// - ///The zero-based index of the element to get. - T this[int index] { get; } - - /// - /// Gets the number of elements contained on this page. - /// - int Count { get; } - + /// + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. + /// + /// + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. + /// + /// The type of object the collection should contain. + /// + [PublicAPI] + public interface IPagedList : IPagedList, IReadOnlyList + { /// /// Gets a non-enumerable copy of this paged list. /// ///A non-enumerable copy of this paged list. PagedListMetaData GetMetaData(); - } + } - /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. - /// - /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. - /// - public interface IPagedList - { - /// - /// Total number of subsets within the superset. - /// - /// - /// Total number of subsets within the superset. - /// - int PageCount { get; } + /// + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. + /// + /// + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. + /// + public interface IPagedList + { + /// + /// Total number of subsets within the superset. + /// + /// + /// Total number of subsets within the superset. + /// + int PageCount { get; } - /// - /// Total number of objects contained within the superset. - /// - /// - /// Total number of objects contained within the superset. - /// - int TotalItemCount { get; } + /// + /// Total number of objects contained within the superset. + /// + /// + /// Total number of objects contained within the superset. + /// + int TotalItemCount { get; } - /// - /// One-based index of this subset within the superset, zero if the superset is empty. - /// - /// - /// One-based index of this subset within the superset, zero if the superset is empty. - /// - int PageNumber { get; } + /// + /// One-based index of this subset within the superset, zero if the superset is empty. + /// + /// + /// One-based index of this subset within the superset, zero if the superset is empty. + /// + int PageNumber { get; } - /// - /// Maximum size any individual subset. - /// - /// - /// Maximum size any individual subset. - /// - int PageSize { get; } + /// + /// Maximum size any individual subset. + /// + /// + /// Maximum size any individual subset. + /// + int PageSize { get; } - /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is NOT the first subset within the superset. - /// - /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is NOT the first subset within the superset. - /// - bool HasPreviousPage { get; } + /// + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is NOT the first subset within the superset. + /// + /// + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is NOT the first subset within the superset. + /// + bool HasPreviousPage { get; } - /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is NOT the last subset within the superset. - /// - /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is NOT the last subset within the superset. - /// - bool HasNextPage { get; } + /// + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is NOT the last subset within the superset. + /// + /// + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is NOT the last subset within the superset. + /// + bool HasNextPage { get; } - /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is the first subset within the superset. - /// - /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is the first subset within the superset. - /// - bool IsFirstPage { get; } + /// + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is the first subset within the superset. + /// + /// + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is the first subset within the superset. + /// + bool IsFirstPage { get; } - /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is the last subset within the superset. - /// - /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is the last subset within the superset. - /// - bool IsLastPage { get; } + /// + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is the last subset within the superset. + /// + /// + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is the last subset within the superset. + /// + bool IsLastPage { get; } - /// - /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber is greater than PageCount. - /// - /// - /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber is greater than PageCount. - /// - int FirstItemOnPage { get; } + /// + /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber + /// is greater than PageCount. + /// + /// + /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber + /// is greater than PageCount. + /// + int FirstItemOnPage { get; } - /// - /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber is greater than PageCount. - /// - /// - /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber is greater than PageCount. - /// - int LastItemOnPage { get; } - } + /// + /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber + /// is greater than PageCount. + /// + /// + /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber + /// is greater than PageCount. + /// + int LastItemOnPage { get; } + } } \ No newline at end of file diff --git a/src/X.PagedList/PagedList.cs b/src/X.PagedList/PagedList.cs index 9c57fa83..b21c902a 100644 --- a/src/X.PagedList/PagedList.cs +++ b/src/X.PagedList/PagedList.cs @@ -2,17 +2,26 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using JetBrains.Annotations; namespace X.PagedList { + [PublicAPI] public class PagedList : BasePagedList { /// - /// Initializes a new instance of the class that divides the supplied superset into subsets the size of the supplied pageSize. The instance then only containes the objects contained in the subset specified by index. + /// Initializes a new instance of the class that divides the supplied superset into + /// subsets the size of the supplied pageSize. The instance then only contains the objects contained in the + /// subset specified by index. /// - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// /// Expression for Order - /// The one-based index of the subset of objects to be contained by this instance. + /// + /// The one-based index of the subset of objects to be contained by this instance. + /// /// The maximum size of any individual subset. /// The specified index cannot be less than zero. /// The specified page size cannot be less than one. @@ -48,10 +57,12 @@ private void InitSubset(IEnumerable superset, Func keySelectorMethod } /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. /// /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. /// /// The type of object the collection should contain. /// @@ -61,17 +72,24 @@ private void InitSubset(IEnumerable superset, Func keySelectorMethod public class PagedList : BasePagedList { /// - /// Initializes a new instance of the class that divides the supplied superset into subsets the size of the supplied pageSize. The instance then only containes the objects contained in the subset specified by index. + /// Initializes a new instance of the class that divides the supplied superset + /// into subsets the size of the supplied pageSize. The instance then only contains the objects contained + /// in the subset specified by index. /// - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. - /// The one-based index of the subset of objects to be contained by this instance. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// + /// + /// The one-based index of the subset of objects to be contained by this instance. + /// /// The maximum size of any individual subset. /// The specified index cannot be less than zero. /// The specified page size cannot be less than one. public PagedList(IQueryable superset, int pageNumber, int pageSize) : base(pageNumber, pageSize, superset?.Count() ?? 0) { - if (TotalItemCount > 0) + if (TotalItemCount > 0 && superset != null) { Subset.AddRange(pageNumber == 1 ? superset.Take(pageSize).ToList() @@ -81,9 +99,14 @@ public PagedList(IQueryable superset, int pageNumber, int pageSize) } /// - /// Initializes a new instance of the class that divides the supplied superset into subsets the size of the supplied pageSize. The instance then only containes the objects contained in the subset specified by index. + /// Initializes a new instance of the class that divides the supplied superset + /// into subsets the size of the supplied pageSize. The instance then only contains the objects contained in + /// the subset specified by index. /// - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// /// The one-based index of the subset of objects to be contained by this instance. /// The maximum size of any individual subset. /// The specified index cannot be less than zero. diff --git a/src/X.PagedList/PagedListExtensions.cs b/src/X.PagedList/PagedListExtensions.cs index c25b4488..9316f4d4 100644 --- a/src/X.PagedList/PagedListExtensions.cs +++ b/src/X.PagedList/PagedListExtensions.cs @@ -4,16 +4,19 @@ using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; +using JetBrains.Annotations; namespace X.PagedList { /// /// Container for extension methods designed to simplify the creation of instances of . /// + [PublicAPI] public static class PagedListExtensions { /// - /// Splits a collection of objects into n pages with an (for example, if I have a list of 45 shoes and say 'shoes.Split(5)' I will now have 4 pages of 10 shoes and 1 page of 5 shoes. + /// Splits a collection of objects into n pages with an (for example, if I have a list of 45 shoes and + /// say 'shoes.Split(5)' I will now have 4 pages of 10 shoes and 1 page of 5 shoes. /// /// The type of object the collection should contain. /// The collection of objects to be divided into subsets. @@ -39,7 +42,9 @@ public static IEnumerable> Split(this IEnumerable superset, } /// - /// Splits a collection of objects into an unknown number of pages with n items per page (for example, if I have a list of 45 shoes and say 'shoes.Partition(10)' I will now have 4 pages of 10 shoes and 1 page of 5 shoes. + /// Splits a collection of objects into an unknown number of pages with n items per page (for example, + /// if I have a list of 45 shoes and say 'shoes.Partition(10)' I will now have 4 pages of 10 shoes and + /// 1 page of 5 shoes. /// /// The type of object the collection should contain. /// The collection of objects to be divided into subsets. @@ -48,7 +53,7 @@ public static IEnumerable> Split(this IEnumerable superset, public static IEnumerable> Partition(this IEnumerable superset, int pageSize) { // Cache this to avoid evaluating it twice - int count = superset.Count(); + var count = superset.Count(); if (count < pageSize) { @@ -66,13 +71,20 @@ public static IEnumerable> Partition(this IEnumerable super } /// - /// 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. + /// 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. /// /// The type of object the collection should contain. - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. - /// The one-based index of the subset of objects to be contained by this instance. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// + /// + /// The one-based index of the subset of objects to be contained by this instance. + /// /// The maximum size of any individual subset. - /// 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. + /// 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. /// public static IPagedList ToPagedList(this IEnumerable superset, int pageNumber, int pageSize) { @@ -80,11 +92,16 @@ public static IPagedList ToPagedList(this IEnumerable superset, int pag } /// - /// 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. + /// 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. /// /// The type of object the collection should contain. - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. - /// 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. + /// + /// The collection of objects to be divided into subsets. If the + /// collection implements , it will be treated as such. + /// + /// 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. /// public static IPagedList ToPagedList(this IEnumerable superset) { @@ -108,41 +125,64 @@ public static IPagedList Select(this IPagedList - /// 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. + /// 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. /// /// The type of object the collection should contain. /// Type For Compare - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// /// Expression for Order - /// The one-based index of the subset of objects to be contained by this instance. + /// + /// The one-based index of the subset of objects to be contained by this instance. + /// /// The maximum size of any individual subset. - /// 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. + /// + /// 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. + /// public static IPagedList ToPagedList(this IQueryable superset, Expression> keySelector, int pageNumber, int pageSize) { return new PagedList(superset, keySelector, pageNumber, pageSize); } /// - /// 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. + /// 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. /// /// The type of object the collection should contain. /// Type For Compare - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// /// Expression for Order /// The one-based index of the subset of objects to be contained by this instance. /// The maximum size of any individual subset. - /// 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. + /// + /// 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. + /// public static IPagedList ToPagedList(this IEnumerable superset, Expression> keySelector, int pageNumber, int pageSize) { return new PagedList(superset.AsQueryable(), keySelector, pageNumber, pageSize); } /// - /// Async 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. + /// Async 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. /// /// The type of object the collection should contain. - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. - /// 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. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// + /// + /// 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. + /// /// public static async Task> ToListAsync(this IEnumerable superset) { @@ -150,27 +190,38 @@ public static async Task> ToListAsync(this IEnumerable superset) } /// - /// Async 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. + /// Async 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. /// /// The type of object the collection should contain. - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// /// - /// 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. + /// + /// 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. + /// /// public static async Task> ToListAsync(this IEnumerable superset, CancellationToken cancellationToken) { - return await Task.Run(() => superset.ToList(), cancellationToken); + return await Task.Run(superset.ToList, cancellationToken); } /// - /// Async 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. + /// Async 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. /// /// The type of object the collection should contain. /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. /// The one-based index of the subset of objects to be contained by this instance. /// The maximum size of any individual subset. /// - /// 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. + /// + /// 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. + /// /// public static async Task> ToPagedListAsync(this IQueryable superset, int pageNumber, int pageSize, CancellationToken cancellationToken) { @@ -204,13 +255,22 @@ public static async Task> ToPagedListAsync(this IQueryable s } /// - /// Async 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. + /// Async 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. /// /// The type of object the collection should contain. - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. - /// The one-based index of the subset of objects to be contained by this instance. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// + /// + /// The one-based index of the subset of objects to be contained by this instance. + /// /// The maximum size of any individual subset. - /// 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. + /// + /// 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. + /// /// public static async Task> ToPagedListAsync(this IQueryable superset, int pageNumber, int pageSize) { @@ -218,14 +278,23 @@ public static async Task> ToPagedListAsync(this IQueryable s } /// - /// 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. + /// 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. /// /// The type of object the collection should contain. - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. - /// The one-based index of the subset of objects to be contained by this instance. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// + /// + /// The one-based index of the subset of objects to be contained by this instance. + /// /// The maximum size of any individual subset. /// - /// 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. + /// + /// 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. + /// /// public static async Task> ToPagedListAsync(this IEnumerable superset, int pageNumber, int pageSize, CancellationToken cancellationToken) { @@ -233,13 +302,22 @@ public static async Task> ToPagedListAsync(this IEnumerable } /// - /// 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. + /// 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. /// /// The type of object the collection should contain. - /// The collection of objects to be divided into subsets. If the collection implements , it will be treated as such. - /// The one-based index of the subset of objects to be contained by this instance. + /// + /// The collection of objects to be divided into subsets. If the collection + /// implements , it will be treated as such. + /// + /// + /// The one-based index of the subset of objects to be contained by this instance. + /// /// The maximum size of any individual subset. - /// 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. + /// + /// 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. + /// /// public static async Task> ToPagedListAsync(this IEnumerable superset, int pageNumber, int pageSize) { @@ -247,14 +325,20 @@ public static async Task> ToPagedListAsync(this IEnumerable } /// - /// Async creates a subset of this collection of objects that can be individually accessed by index (defaulting to the first page) and containing metadata about the collection of objects the subset was created from. + /// Async creates a subset of this collection of objects that can be individually accessed by index (defaulting + /// to the first page) and containing metadata about the collection of objects the subset was created from. /// /// The type of object the collection should contain. /// - /// The one-based index of the subset of objects to be contained by this instance, defaulting to the first page. + /// + /// The one-based index of the subset of objects to be contained by this instance, defaulting to the first page. + /// /// The maximum size of any individual subset. /// - /// 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. + /// + /// 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. + /// /// public static async Task> ToPagedListAsync(this IQueryable superset, int? pageNumber, int pageSize, CancellationToken cancellationToken) { @@ -262,13 +346,21 @@ public static async Task> ToPagedListAsync(this IQueryable s } /// - /// Async creates a subset of this collection of objects that can be individually accessed by index (defaulting to the first page) and containing metadata about the collection of objects the subset was created from. + /// Async creates a subset of this collection of objects that can be individually accessed by index + /// (defaulting to the first page) and containing metadata about the collection of objects the subset + /// was created from. /// /// The type of object the collection should contain. /// - /// The one-based index of the subset of objects to be contained by this instance, defaulting to the first page. + /// + /// The one-based index of the subset of objects to be contained by this instance, + /// defaulting to the first page. + /// /// The maximum size of any individual subset. - /// 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. + /// + /// 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. + /// /// public static async Task> ToPagedListAsync(this IQueryable superset, int? pageNumber, int pageSize) { diff --git a/src/X.PagedList/PagedListMetaData.cs b/src/X.PagedList/PagedListMetaData.cs index f0cd49bb..23b90252 100644 --- a/src/X.PagedList/PagedListMetaData.cs +++ b/src/X.PagedList/PagedListMetaData.cs @@ -1,8 +1,11 @@ -namespace X.PagedList +using JetBrains.Annotations; + +namespace X.PagedList { /// /// Non-enumerable version of the PagedList class. /// + [PublicAPI] public class PagedListMetaData : IPagedList { /// @@ -73,42 +76,52 @@ public PagedListMetaData(IPagedList pagedList) public bool HasPreviousPage { get; protected set; } /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is NOT the last subset within the superset. + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is NOT the last subset within the superset. /// /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is NOT the last subset within the superset. + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is NOT the last subset within the superset. /// public bool HasNextPage { get; protected set; } /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is the first subset within the superset. + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is the first subset within the superset. /// /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is the first subset within the superset. + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and + /// this is the first subset within the superset. /// public bool IsFirstPage { get; protected set; } /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is the last subset within the superset. + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and + /// this is the last subset within the superset. /// /// - /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this is the last subset within the superset. + /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this + /// is the last subset within the superset. /// public bool IsLastPage { get; protected set; } /// - /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber is greater than PageCount. + /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber + /// is greater than PageCount. /// /// - /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber is greater than PageCount. + /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber + /// is greater than PageCount. /// public int FirstItemOnPage { get; protected set; } /// - /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber is greater than PageCount. + /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber + /// is greater than PageCount. /// /// - /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber is greater than PageCount. + /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber + /// is greater than PageCount. /// public int LastItemOnPage { get; protected set; } diff --git a/src/X.PagedList/StaticPagedList.cs b/src/X.PagedList/StaticPagedList.cs index bcc086b8..c785cfd5 100644 --- a/src/X.PagedList/StaticPagedList.cs +++ b/src/X.PagedList/StaticPagedList.cs @@ -1,25 +1,35 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using JetBrains.Annotations; namespace X.PagedList { /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. /// /// - /// Represents a subset of a collection of objects that can be individually accessed by index and containing metadata about the superset collection of objects this subset was created from. + /// Represents a subset of a collection of objects that can be individually accessed by index and containing + /// metadata about the superset collection of objects this subset was created from. /// /// The type of object the collection should contain. /// /// /// /// + [PublicAPI] public class StaticPagedList : BasePagedList { /// - /// Initializes a new instance of the class that contains the already divided subset and information about the size of the superset and the subset's position within it. + /// Initializes a new instance of the class that contains the already + /// divided subset and information about the size of the superset and the subset's position within it. /// /// The single subset this collection should represent. - /// Supply the ".MetaData" property of an existing IPagedList instance to recreate it here (such as when creating a new instance of a PagedList after having used Automapper to convert its contents to a DTO.) + /// + /// Supply the ".MetaData" property of an existing IPagedList instance to recreate + /// it here (such as when creating a new instance of a PagedList after having used Automapper to convert + /// its contents to a DTO.) + /// /// The specified index cannot be less than zero. /// The specified page size cannot be less than one. public StaticPagedList(IEnumerable subset, IPagedList metaData) @@ -28,7 +38,8 @@ public StaticPagedList(IEnumerable subset, IPagedList metaData) } /// - /// Initializes a new instance of the class that contains the already divided subset and information about the size of the superset and the subset's position within it. + /// Initializes a new instance of the class that contains the already + /// divided subset and information about the size of the superset and the subset's position within it. /// /// The single subset this collection should represent. /// The one-based index of the subset of objects contained by this instance. diff --git a/src/X.PagedList/X.PagedList.csproj b/src/X.PagedList/X.PagedList.csproj index a17ef93b..df78fc83 100644 --- a/src/X.PagedList/X.PagedList.csproj +++ b/src/X.PagedList/X.PagedList.csproj @@ -20,6 +20,7 @@ + diff --git a/tests/X.PagedList.Tests/X.PagedList.Tests.csproj b/tests/X.PagedList.Tests/X.PagedList.Tests.csproj index 6e598484..bddd1070 100644 --- a/tests/X.PagedList.Tests/X.PagedList.Tests.csproj +++ b/tests/X.PagedList.Tests/X.PagedList.Tests.csproj @@ -5,9 +5,9 @@ - + - + all runtime; build; native; contentfiles; analyzers