From 9f2eb42d538e87c4c16cc0b734766afcabc52522 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:22:49 +0300 Subject: [PATCH 01/19] Update version --- src/Directory.Build.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index f578df0f..81ae4aa5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -13,10 +13,10 @@ https://github.com/dncuug/X.PagedList https://ru.gravatar.com/userimage/8071071/f2dc08ee7e4016451f64a7ae9cffd110.png?size=200 - 10.0.3 - 10.0.3 - 10.0.3 - 10.0.3-pre + 11.0.1 + 11.0.1 + 11.0.1 + 11.0.1-pre git https://github.com/dncuug/X.PagedList.git From 2d91bc058f25297dcbb360b1aca74bdceb23834f Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:25:11 +0300 Subject: [PATCH 02/19] Remove PagedListMetaData --- src/X.PagedList/BasePagedList.cs | 96 +++++++++++++++++++- src/X.PagedList/IPagedList.cs | 2 +- src/X.PagedList/PagedListMetaData.cs | 131 --------------------------- 3 files changed, 94 insertions(+), 135 deletions(-) delete mode 100644 src/X.PagedList/PagedListMetaData.cs diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index 50c14810..e40781ec 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -17,11 +17,101 @@ namespace X.PagedList; /// /// [PublicAPI] -public abstract class BasePagedList : PagedListMetaData, IPagedList +public abstract class BasePagedList : IPagedList { protected List Subset = new(); public const int DefaultPageSize = 100; + + /// + /// Total number of subsets within the superset. + /// + /// + /// Total number of subsets within the superset. + /// + public int PageCount { get; protected set; } + + /// + /// Total number of objects contained within the superset. + /// + /// + /// Total number of objects contained within the superset. + /// + public int TotalItemCount { get; protected set; } + + /// + /// 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. + /// + public int PageNumber { get; protected set; } + + /// + /// Maximum size any individual subset. + /// + /// + /// Maximum size any individual subset. + /// + public int PageSize { 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 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. + /// + 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. + /// + 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. + /// + 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. + /// + 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. + /// + 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. + /// + public int LastItemOnPage { get; protected set; } /// /// Parameterless constructor. @@ -117,8 +207,8 @@ IEnumerator IEnumerable.GetEnumerator() /// ///A non-enumerable copy of this paged list. [Obsolete("This method will be removed in future versions")] - public PagedListMetaData GetMetaData() + public IPagedList GetMetaData() { - return new PagedListMetaData(this); + return new StaticPagedList(new List(), this); } } diff --git a/src/X.PagedList/IPagedList.cs b/src/X.PagedList/IPagedList.cs index 839a1a25..e17aff18 100644 --- a/src/X.PagedList/IPagedList.cs +++ b/src/X.PagedList/IPagedList.cs @@ -20,7 +20,7 @@ public interface IPagedList : IPagedList, IReadOnlyList /// Gets a non-enumerable copy of this paged list. /// ///A non-enumerable copy of this paged list. - PagedListMetaData GetMetaData(); + IPagedList GetMetaData(); } /// diff --git a/src/X.PagedList/PagedListMetaData.cs b/src/X.PagedList/PagedListMetaData.cs deleted file mode 100644 index 17a33ae9..00000000 --- a/src/X.PagedList/PagedListMetaData.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System; -using JetBrains.Annotations; - -namespace X.PagedList; - -/// -/// Non-enumerable version of the PagedList class. -/// -[PublicAPI] -[Obsolete("This class will be removed in future versions")] -public class PagedListMetaData : IPagedList -{ - /// - /// Protected constructor that allows for instantiation without passing in a separate list. - /// - protected PagedListMetaData() - { - } - - /// - /// Non-enumerable version of the PagedList class. - /// - ///A PagedList (likely enumerable) to copy metadata from. - public PagedListMetaData(IPagedList pagedList) - { - PageCount = pagedList.PageCount; - TotalItemCount = pagedList.TotalItemCount; - PageNumber = pagedList.PageNumber; - PageSize = pagedList.PageSize; - HasPreviousPage = pagedList.HasPreviousPage; - HasNextPage = pagedList.HasNextPage; - IsFirstPage = pagedList.IsFirstPage; - IsLastPage = pagedList.IsLastPage; - FirstItemOnPage = pagedList.FirstItemOnPage; - LastItemOnPage = pagedList.LastItemOnPage; - } - - #region IPagedList Members - - /// - /// Total number of subsets within the superset. - /// - /// - /// Total number of subsets within the superset. - /// - public int PageCount { get; protected set; } - - /// - /// Total number of objects contained within the superset. - /// - /// - /// Total number of objects contained within the superset. - /// - public int TotalItemCount { get; protected set; } - - /// - /// 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. - /// - public int PageNumber { get; protected set; } - - /// - /// Maximum size any individual subset. - /// - /// - /// Maximum size any individual subset. - /// - public int PageSize { 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 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. - /// - 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. - /// - 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. - /// - 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. - /// - 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. - /// - 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. - /// - public int LastItemOnPage { get; protected set; } - - #endregion -} From 766aac049ac59de642c6b05d5235fe760585d9ec Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:38:01 +0300 Subject: [PATCH 03/19] Cleanup code --- src/X.PagedList.Mvc.Core/HtmlHelper.cs | 67 +++++++++----------------- src/X.PagedList/IPagedList.cs | 4 +- 2 files changed, 27 insertions(+), 44 deletions(-) diff --git a/src/X.PagedList.Mvc.Core/HtmlHelper.cs b/src/X.PagedList.Mvc.Core/HtmlHelper.cs index 0b015735..5bac4822 100644 --- a/src/X.PagedList.Mvc.Core/HtmlHelper.cs +++ b/src/X.PagedList.Mvc.Core/HtmlHelper.cs @@ -16,8 +16,6 @@ public HtmlHelper(ITagBuilderFactory tagBuilderFactory) _tagBuilderFactory = tagBuilderFactory; } - #region Private methods - private static void SetInnerText(TagBuilder tagBuilder, string innerText) { tagBuilder.SetInnerText(innerText); @@ -30,20 +28,17 @@ private static void AppendHtml(TagBuilder tagBuilder, string innerHtml) private static string TagBuilderToString(TagBuilder tagBuilder) { - return tagBuilder - .ToString(TagRenderMode.Normal); + return tagBuilder.ToString(TagRenderMode.Normal); } private static string TagBuilderToString(TagBuilder tagBuilder, TagRenderMode renderMode) { - return tagBuilder - .ToString(renderMode); + return tagBuilder.ToString(renderMode); } private TagBuilder WrapInListItem(string text) { - var li = _tagBuilderFactory - .Create("li"); + var li = _tagBuilderFactory.Create("li"); SetInnerText(li, text); @@ -72,8 +67,8 @@ private TagBuilder WrapInListItem(TagBuilder inner, PagedListRenderOptions? opti private TagBuilder First(IPagedList list, Func generatePageUrl, PagedListRenderOptions options) { const int targetPageNumber = 1; - var first = _tagBuilderFactory - .Create("a"); + + var first = _tagBuilderFactory.Create("a"); AppendHtml(first, string.Format(options.LinkToFirstPageFormat, targetPageNumber)); @@ -95,8 +90,8 @@ private TagBuilder First(IPagedList list, Func generatePageUrl, Pa private TagBuilder Previous(IPagedList list, Func generatePageUrl, PagedListRenderOptions options) { var targetPageNumber = list.PageNumber - 1; - var previous = _tagBuilderFactory - .Create("a"); + + var previous = _tagBuilderFactory.Create("a"); AppendHtml(previous, string.Format(options.LinkToPreviousPageFormat, targetPageNumber)); @@ -121,12 +116,12 @@ private TagBuilder Page(int i, IPagedList list, Func generatePageU { var format = options.FunctionToDisplayEachPageNumber ?? (pageNumber => string.Format(options.LinkToIndividualPageFormat, pageNumber)); + var targetPageNumber = i; + var page = i == list.PageNumber - ? _tagBuilderFactory - .Create("span") - : _tagBuilderFactory - .Create("a"); + ? _tagBuilderFactory.Create("span") + : _tagBuilderFactory.Create("a"); SetInnerText(page, format(targetPageNumber)); @@ -148,8 +143,7 @@ private TagBuilder Page(int i, IPagedList list, Func generatePageU private TagBuilder Next(IPagedList list, Func generatePageUrl, PagedListRenderOptions options) { var targetPageNumber = list.PageNumber + 1; - var next = _tagBuilderFactory - .Create("a"); + var next = _tagBuilderFactory.Create("a"); AppendHtml(next, string.Format(options.LinkToNextPageFormat, targetPageNumber)); @@ -173,8 +167,7 @@ private TagBuilder Next(IPagedList list, Func generatePageUrl, Pag private TagBuilder Last(IPagedList list, Func generatePageUrl, PagedListRenderOptions options) { var targetPageNumber = list.PageCount; - var last = _tagBuilderFactory - .Create("a"); + var last = _tagBuilderFactory.Create("a"); AppendHtml(last, string.Format(options.LinkToLastPageFormat, targetPageNumber)); @@ -195,8 +188,7 @@ private TagBuilder Last(IPagedList list, Func generatePageUrl, Pag private TagBuilder PageCountAndLocationText(IPagedList list, PagedListRenderOptions options) { - var text = _tagBuilderFactory - .Create("a"); + var text = _tagBuilderFactory.Create("a"); SetInnerText(text, string.Format(options.PageCountAndCurrentLocationFormat, list.PageNumber, list.PageCount)); @@ -205,8 +197,7 @@ private TagBuilder PageCountAndLocationText(IPagedList list, PagedListRenderOpti private TagBuilder ItemSliceAndTotalText(IPagedList list, PagedListRenderOptions options) { - var text = _tagBuilderFactory - .Create("a"); + var text = _tagBuilderFactory.Create("a"); SetInnerText(text, string.Format(options.ItemSliceAndTotalFormat, list.FirstItemOnPage, list.LastItemOnPage, list.TotalItemCount)); @@ -215,8 +206,7 @@ private TagBuilder ItemSliceAndTotalText(IPagedList list, PagedListRenderOptions private TagBuilder PreviousEllipsis(IPagedList list, Func generatePageUrl, PagedListRenderOptions options, int firstPageToDisplay) { - var previous = _tagBuilderFactory - .Create("a"); + var previous = _tagBuilderFactory.Create("a"); AppendHtml(previous, options.EllipsesFormat); @@ -242,8 +232,7 @@ private TagBuilder PreviousEllipsis(IPagedList list, Func generate private TagBuilder NextEllipsis(IPagedList list, Func generatePageUrl, PagedListRenderOptions options, int lastPageToDisplay) { - var next = _tagBuilderFactory - .Create("a"); + var next = _tagBuilderFactory.Create("a"); AppendHtml(next, options.EllipsesFormat); @@ -267,8 +256,6 @@ private TagBuilder NextEllipsis(IPagedList list, Func generatePage return WrapInListItem(next, options, options.EllipsesElementClass); } - #endregion Private methods - public string? PagedListPager(IPagedList? pagedList, Func generatePageUrl, PagedListRenderOptions options) { var list = pagedList ?? new StaticPagedList(ImmutableList.Empty, 1, 10, 0); @@ -405,14 +392,13 @@ private TagBuilder NextEllipsis(IPagedList list, Func generatePage } } - //collapse all of the list items into one big string + //Collapse all the list items into one big string var listItemLinksString = listItemLinks.Aggregate( new StringBuilder(), (sb, listItem) => sb.Append(TagBuilderToString(listItem)), sb => sb.ToString()); - var ul = _tagBuilderFactory - .Create("ul"); + var ul = _tagBuilderFactory.Create("ul"); AppendHtml(ul, listItemLinksString); @@ -444,25 +430,21 @@ private TagBuilder NextEllipsis(IPagedList list, Func generatePage public string PagedListGoToPageForm(IPagedList list, string formAction, GoToFormRenderOptions options) { - var form = _tagBuilderFactory - .Create("form"); + var form = _tagBuilderFactory.Create("form"); form.AddCssClass("PagedList-goToPage"); form.Attributes.Add("action", formAction); form.Attributes.Add("method", "get"); - var fieldset = _tagBuilderFactory - .Create("fieldset"); + var fieldset = _tagBuilderFactory.Create("fieldset"); - var label = _tagBuilderFactory - .Create("label"); + var label = _tagBuilderFactory.Create("label"); label.Attributes.Add("for", options.InputFieldName); SetInnerText(label, options.LabelFormat); - var input = _tagBuilderFactory - .Create("input"); + var input = _tagBuilderFactory.Create("input"); input.Attributes.Add("type", options.InputFieldType); input.Attributes.Add("name", options.InputFieldName); @@ -470,8 +452,7 @@ public string PagedListGoToPageForm(IPagedList list, string formAction, GoToForm input.Attributes.Add("class", options.InputFieldClass); input.Attributes.Add("Style", $"width: {options.InputWidth}px"); - var submit = _tagBuilderFactory - .Create("input"); + var submit = _tagBuilderFactory.Create("input"); submit.Attributes.Add("type", "submit"); submit.Attributes.Add("value", options.SubmitButtonFormat); diff --git a/src/X.PagedList/IPagedList.cs b/src/X.PagedList/IPagedList.cs index e17aff18..063ed2e8 100644 --- a/src/X.PagedList/IPagedList.cs +++ b/src/X.PagedList/IPagedList.cs @@ -1,4 +1,5 @@ -using JetBrains.Annotations; +using System; +using JetBrains.Annotations; using System.Collections.Generic; namespace X.PagedList; @@ -20,6 +21,7 @@ public interface IPagedList : IPagedList, IReadOnlyList /// Gets a non-enumerable copy of this paged list. /// ///A non-enumerable copy of this paged list. + [Obsolete("This method will be removed in future versions")] IPagedList GetMetaData(); } From 57a2b87ac378d5b66bfcdf954f2cc89cab1b3fb4 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:55:26 +0300 Subject: [PATCH 04/19] Simplify properties logic --- src/X.PagedList/BasePagedList.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index e86746a9..467c6de8 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -63,20 +63,18 @@ protected internal BasePagedList(int pageNumber, int pageSize, int totalItemCoun ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) : 0; - bool pageNumberIsGood = PageCount > 0 && PageNumber <= PageCount; - - HasPreviousPage = pageNumberIsGood && PageNumber > 1; - HasNextPage = pageNumberIsGood && PageNumber < PageCount; - IsFirstPage = pageNumberIsGood && PageNumber == 1; - IsLastPage = pageNumberIsGood && PageNumber == PageCount; + HasPreviousPage = PageCount > 0 && PageNumber <= PageCount && PageNumber > 1; + HasNextPage = PageCount > 0 && PageNumber <= PageCount && PageNumber < PageCount; + IsFirstPage = PageCount > 0 && PageNumber <= PageCount && PageNumber == 1; + IsLastPage = PageCount > 0 && PageNumber <= PageCount && PageNumber == PageCount; int numberOfFirstItemOnPage = (PageNumber - 1) * PageSize + 1; - FirstItemOnPage = pageNumberIsGood ? numberOfFirstItemOnPage : 0; + FirstItemOnPage = PageCount > 0 && PageNumber <= PageCount ? numberOfFirstItemOnPage : 0; int numberOfLastItemOnPage = numberOfFirstItemOnPage + PageSize - 1; - LastItemOnPage = pageNumberIsGood + LastItemOnPage = PageCount > 0 && PageNumber <= PageCount ? numberOfLastItemOnPage > TotalItemCount ? TotalItemCount : numberOfLastItemOnPage : 0; } From 66250f633043c4a494a24c8aba80ffdc8b48ac78 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:22:49 +0300 Subject: [PATCH 05/19] Update version --- src/Directory.Build.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index f578df0f..81ae4aa5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -13,10 +13,10 @@ https://github.com/dncuug/X.PagedList https://ru.gravatar.com/userimage/8071071/f2dc08ee7e4016451f64a7ae9cffd110.png?size=200 - 10.0.3 - 10.0.3 - 10.0.3 - 10.0.3-pre + 11.0.1 + 11.0.1 + 11.0.1 + 11.0.1-pre git https://github.com/dncuug/X.PagedList.git From 6ccaed138cede6a52490364b8299c191dc40c5b2 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:25:11 +0300 Subject: [PATCH 06/19] Remove PagedListMetaData --- src/X.PagedList/BasePagedList.cs | 96 +++++++++++++++++++- src/X.PagedList/IPagedList.cs | 2 +- src/X.PagedList/PagedListMetaData.cs | 127 --------------------------- 3 files changed, 94 insertions(+), 131 deletions(-) delete mode 100644 src/X.PagedList/PagedListMetaData.cs diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index 467c6de8..fdd6add0 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -17,11 +17,101 @@ namespace X.PagedList; /// /// [PublicAPI] -public abstract class BasePagedList : PagedListMetaData, IPagedList +public abstract class BasePagedList : IPagedList { protected List Subset = new(); public const int DefaultPageSize = 100; + + /// + /// Total number of subsets within the superset. + /// + /// + /// Total number of subsets within the superset. + /// + public int PageCount { get; protected set; } + + /// + /// Total number of objects contained within the superset. + /// + /// + /// Total number of objects contained within the superset. + /// + public int TotalItemCount { get; protected set; } + + /// + /// 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. + /// + public int PageNumber { get; protected set; } + + /// + /// Maximum size any individual subset. + /// + /// + /// Maximum size any individual subset. + /// + public int PageSize { 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 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. + /// + 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. + /// + 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. + /// + 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. + /// + 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. + /// + 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. + /// + public int LastItemOnPage { get; protected set; } /// /// Parameterless constructor. @@ -113,8 +203,8 @@ IEnumerator IEnumerable.GetEnumerator() /// ///A non-enumerable copy of this paged list. [Obsolete("This method will be removed in future versions")] - public PagedListMetaData GetMetaData() + public IPagedList GetMetaData() { - return new PagedListMetaData(this); + return new StaticPagedList(new List(), this); } } diff --git a/src/X.PagedList/IPagedList.cs b/src/X.PagedList/IPagedList.cs index a30891a8..063ed2e8 100644 --- a/src/X.PagedList/IPagedList.cs +++ b/src/X.PagedList/IPagedList.cs @@ -22,7 +22,7 @@ public interface IPagedList : IPagedList, IReadOnlyList /// ///A non-enumerable copy of this paged list. [Obsolete("This method will be removed in future versions")] - PagedListMetaData GetMetaData(); + IPagedList GetMetaData(); } /// diff --git a/src/X.PagedList/PagedListMetaData.cs b/src/X.PagedList/PagedListMetaData.cs deleted file mode 100644 index 68e3805f..00000000 --- a/src/X.PagedList/PagedListMetaData.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using JetBrains.Annotations; - -namespace X.PagedList; - -/// -/// Non-enumerable version of the PagedList class. -/// -[PublicAPI] -[Obsolete("This class will be removed in future versions")] -public class PagedListMetaData : IPagedList -{ - /// - /// Protected constructor that allows for instantiation without passing in a separate list. - /// - protected PagedListMetaData() - { - } - - /// - /// Non-enumerable version of the PagedList class. - /// - ///A PagedList (likely enumerable) to copy metadata from. - public PagedListMetaData(IPagedList pagedList) - { - PageCount = pagedList.PageCount; - TotalItemCount = pagedList.TotalItemCount; - PageNumber = pagedList.PageNumber; - PageSize = pagedList.PageSize; - HasPreviousPage = pagedList.HasPreviousPage; - HasNextPage = pagedList.HasNextPage; - IsFirstPage = pagedList.IsFirstPage; - IsLastPage = pagedList.IsLastPage; - FirstItemOnPage = pagedList.FirstItemOnPage; - LastItemOnPage = pagedList.LastItemOnPage; - } - - /// - /// Total number of subsets within the superset. - /// - /// - /// Total number of subsets within the superset. - /// - public int PageCount { get; protected set; } - - /// - /// Total number of objects contained within the superset. - /// - /// - /// Total number of objects contained within the superset. - /// - public int TotalItemCount { get; protected set; } - - /// - /// 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. - /// - public int PageNumber { get; protected set; } - - /// - /// Maximum size any individual subset. - /// - /// - /// Maximum size any individual subset. - /// - public int PageSize { 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 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. - /// - 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. - /// - 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. - /// - 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. - /// - 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. - /// - 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. - /// - public int LastItemOnPage { get; protected set; } -} From 3bec1d4771631be705fd013ef467076681d06494 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:58:59 +0300 Subject: [PATCH 07/19] Make filed calculated --- src/X.PagedList/BasePagedList.cs | 12 ++++-------- src/X.PagedList/PagedList.cs | 5 +---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index fdd6add0..b7177d2c 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -61,7 +61,7 @@ public abstract class BasePagedList : IPagedList /// /// 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. /// - public bool HasPreviousPage { get; protected set; } + public bool HasPreviousPage => PageCount > 0 && PageNumber <= PageCount && PageNumber > 1; /// /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this @@ -71,7 +71,7 @@ public abstract class BasePagedList : IPagedList /// 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; } + public bool HasNextPage => PageCount > 0 && PageNumber <= PageCount && PageNumber < PageCount; /// /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and this @@ -81,7 +81,7 @@ public abstract class BasePagedList : IPagedList /// 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; } + public bool IsFirstPage => PageCount > 0 && PageNumber <= PageCount && PageNumber == 1; /// /// Returns true if the superset is not empty and PageNumber is less than or equal to PageCount and @@ -91,7 +91,7 @@ public abstract class BasePagedList : IPagedList /// 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; } + public bool IsLastPage => PageCount > 0 && PageNumber <= PageCount && PageNumber == PageCount; /// /// One-based index of the first item in the paged subset, zero if the superset is empty or PageNumber @@ -153,10 +153,6 @@ protected internal BasePagedList(int pageNumber, int pageSize, int totalItemCoun ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) : 0; - HasPreviousPage = PageCount > 0 && PageNumber <= PageCount && PageNumber > 1; - HasNextPage = PageCount > 0 && PageNumber <= PageCount && PageNumber < PageCount; - IsFirstPage = PageCount > 0 && PageNumber <= PageCount && PageNumber == 1; - IsLastPage = PageCount > 0 && PageNumber <= PageCount && PageNumber == PageCount; int numberOfFirstItemOnPage = (PageNumber - 1) * PageSize + 1; diff --git a/src/X.PagedList/PagedList.cs b/src/X.PagedList/PagedList.cs index b53719f6..d3b8f222 100644 --- a/src/X.PagedList/PagedList.cs +++ b/src/X.PagedList/PagedList.cs @@ -84,10 +84,7 @@ public PagedList(IPagedList pagedList, IEnumerable collection) PageSize = pagedList.PageSize; PageNumber = pagedList.PageNumber; PageCount = pagedList.PageCount; - HasPreviousPage = pagedList.HasPreviousPage; - HasNextPage = pagedList.HasNextPage; - IsFirstPage = pagedList.IsFirstPage; - IsLastPage = pagedList.IsLastPage; + FirstItemOnPage = pagedList.FirstItemOnPage; LastItemOnPage = pagedList.LastItemOnPage; From f4829f8a44c99edfea32d013399c9c3c7b17d1b5 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 17:03:05 +0300 Subject: [PATCH 08/19] Update PageCount property --- src/X.PagedList/BasePagedList.cs | 35 +++++++++++++++----------------- src/X.PagedList/PagedList.cs | 4 ---- 2 files changed, 16 insertions(+), 23 deletions(-) diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index b7177d2c..fb6d112a 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -22,14 +22,14 @@ public abstract class BasePagedList : IPagedList protected List Subset = new(); public const int DefaultPageSize = 100; - + /// /// Total number of subsets within the superset. /// /// /// Total number of subsets within the superset. /// - public int PageCount { get; protected set; } + public int PageCount => TotalItemCount > 0 ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) : 0; /// /// Total number of objects contained within the superset. @@ -101,7 +101,7 @@ public abstract class BasePagedList : IPagedList /// 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; } + public int FirstItemOnPage => PageCount > 0 && PageNumber <= PageCount ? (PageNumber - 1) * PageSize + 1 : 0; /// /// One-based index of the last item in the paged subset, zero if the superset is empty or PageNumber @@ -111,7 +111,19 @@ public abstract class BasePagedList : IPagedList /// 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; } + public int LastItemOnPage + { + get + { + int numberOfLastItemOnPage = (PageNumber - 1) * PageSize + 1 + PageSize - 1; + + var result = PageCount > 0 && PageNumber <= PageCount + ? numberOfLastItemOnPage > TotalItemCount ? TotalItemCount : numberOfLastItemOnPage + : 0; + + return result; + } + } /// /// Parameterless constructor. @@ -148,21 +160,6 @@ protected internal BasePagedList(int pageNumber, int pageSize, int totalItemCoun TotalItemCount = totalItemCount; PageSize = pageSize; PageNumber = pageNumber; - - PageCount = TotalItemCount > 0 - ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) - : 0; - - - int numberOfFirstItemOnPage = (PageNumber - 1) * PageSize + 1; - - FirstItemOnPage = PageCount > 0 && PageNumber <= PageCount ? numberOfFirstItemOnPage : 0; - - int numberOfLastItemOnPage = numberOfFirstItemOnPage + PageSize - 1; - - LastItemOnPage = PageCount > 0 && PageNumber <= PageCount - ? numberOfLastItemOnPage > TotalItemCount ? TotalItemCount : numberOfLastItemOnPage - : 0; } /// diff --git a/src/X.PagedList/PagedList.cs b/src/X.PagedList/PagedList.cs index d3b8f222..b11a521d 100644 --- a/src/X.PagedList/PagedList.cs +++ b/src/X.PagedList/PagedList.cs @@ -83,10 +83,6 @@ public PagedList(IPagedList pagedList, IEnumerable collection) TotalItemCount = pagedList.TotalItemCount; PageSize = pagedList.PageSize; PageNumber = pagedList.PageNumber; - PageCount = pagedList.PageCount; - - FirstItemOnPage = pagedList.FirstItemOnPage; - LastItemOnPage = pagedList.LastItemOnPage; Subset.AddRange(collection); From 869812bcf2fb03a4495eacaf68819d5196c30ec3 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:25:11 +0300 Subject: [PATCH 09/19] Remove PagedListMetaData --- src/X.PagedList/BasePagedList.cs | 90 ++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index fb6d112a..77afdd98 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -22,6 +22,96 @@ public abstract class BasePagedList : IPagedList protected List Subset = new(); public const int DefaultPageSize = 100; + + /// + /// Total number of subsets within the superset. + /// + /// + /// Total number of subsets within the superset. + /// + public int PageCount { get; protected set; } + + /// + /// Total number of objects contained within the superset. + /// + /// + /// Total number of objects contained within the superset. + /// + public int TotalItemCount { get; protected set; } + + /// + /// 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. + /// + public int PageNumber { get; protected set; } + + /// + /// Maximum size any individual subset. + /// + /// + /// Maximum size any individual subset. + /// + public int PageSize { 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 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. + /// + 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. + /// + 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. + /// + 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. + /// + 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. + /// + 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. + /// + public int LastItemOnPage { get; protected set; } /// /// Total number of subsets within the superset. From 676e226761dc8a88b58197b35409c1d98753dc1d Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:29:20 +0300 Subject: [PATCH 10/19] Removed GetMetaData --- src/X.PagedList/BasePagedList.cs | 10 ---------- src/X.PagedList/IPagedList.cs | 10 +--------- 2 files changed, 1 insertion(+), 19 deletions(-) diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index 77afdd98..54c72521 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -280,14 +280,4 @@ IEnumerator IEnumerable.GetEnumerator() /// Gets the number of elements contained on this page. /// public virtual int Count => Subset.Count; - - /// - /// Gets a non-enumerable copy of this paged list. - /// - ///A non-enumerable copy of this paged list. - [Obsolete("This method will be removed in future versions")] - public IPagedList GetMetaData() - { - return new StaticPagedList(new List(), this); - } } diff --git a/src/X.PagedList/IPagedList.cs b/src/X.PagedList/IPagedList.cs index 063ed2e8..b0545a35 100644 --- a/src/X.PagedList/IPagedList.cs +++ b/src/X.PagedList/IPagedList.cs @@ -15,15 +15,7 @@ namespace X.PagedList; /// 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. - [Obsolete("This method will be removed in future versions")] - IPagedList GetMetaData(); -} +public interface IPagedList : IPagedList, IReadOnlyList; /// /// Represents a subset of a collection of objects that can be individually accessed by index and containing From e43c33d3dad2a177ad3110e7a5c5ba011f819a5e Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 16:29:45 +0300 Subject: [PATCH 11/19] Update version --- src/Directory.Build.props | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 81ae4aa5..d995a66c 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -13,10 +13,10 @@ https://github.com/dncuug/X.PagedList https://ru.gravatar.com/userimage/8071071/f2dc08ee7e4016451f64a7ae9cffd110.png?size=200 - 11.0.1 - 11.0.1 - 11.0.1 - 11.0.1-pre + 12.0.1 + 12.0.1 + 12.0.1 + 12.0.1-pre git https://github.com/dncuug/X.PagedList.git From 8bf0c32270cacd2b440055f3dbce72f4c9c12696 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 17:08:07 +0300 Subject: [PATCH 12/19] Fix merge issues --- src/X.PagedList/BasePagedList.cs | 90 -------------------------------- 1 file changed, 90 deletions(-) diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index 54c72521..c347a48e 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -22,96 +22,6 @@ public abstract class BasePagedList : IPagedList protected List Subset = new(); public const int DefaultPageSize = 100; - - /// - /// Total number of subsets within the superset. - /// - /// - /// Total number of subsets within the superset. - /// - public int PageCount { get; protected set; } - - /// - /// Total number of objects contained within the superset. - /// - /// - /// Total number of objects contained within the superset. - /// - public int TotalItemCount { get; protected set; } - - /// - /// 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. - /// - public int PageNumber { get; protected set; } - - /// - /// Maximum size any individual subset. - /// - /// - /// Maximum size any individual subset. - /// - public int PageSize { 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 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. - /// - 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. - /// - 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. - /// - 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. - /// - 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. - /// - 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. - /// - public int LastItemOnPage { get; protected set; } /// /// Total number of subsets within the superset. From ec4735b9a0f0137da143a9141467a49b91d56964 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 17:09:20 +0300 Subject: [PATCH 13/19] Fix merge issues --- src/X.PagedList/BasePagedList.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index c347a48e..c78bfc01 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -19,9 +19,9 @@ namespace X.PagedList; [PublicAPI] public abstract class BasePagedList : IPagedList { - protected List Subset = new(); - public const int DefaultPageSize = 100; + + protected List Subset = new(); /// /// Total number of subsets within the superset. From 155d9ebbdc41a5813b7d7857d48dc06e7e5dbc10 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 17:15:01 +0300 Subject: [PATCH 14/19] Cleanup code --- examples/Example.DAL/Animal.cs | 5 +---- examples/Example.DAL/DatabaseContext.cs | 4 +--- examples/Example.DAL/User.cs | 5 +---- src/X.PagedList/IPagedList.cs | 3 +-- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/examples/Example.DAL/Animal.cs b/examples/Example.DAL/Animal.cs index 6aa15c55..7ef043ef 100644 --- a/examples/Example.DAL/Animal.cs +++ b/examples/Example.DAL/Animal.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace Example.DAL; +namespace Example.DAL; public partial class Animal { diff --git a/examples/Example.DAL/DatabaseContext.cs b/examples/Example.DAL/DatabaseContext.cs index ed35c104..b9dd7803 100644 --- a/examples/Example.DAL/DatabaseContext.cs +++ b/examples/Example.DAL/DatabaseContext.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; namespace Example.DAL; diff --git a/examples/Example.DAL/User.cs b/examples/Example.DAL/User.cs index c65e0c41..5e285883 100644 --- a/examples/Example.DAL/User.cs +++ b/examples/Example.DAL/User.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; - -namespace Example.DAL; +namespace Example.DAL; public partial class User { diff --git a/src/X.PagedList/IPagedList.cs b/src/X.PagedList/IPagedList.cs index b0545a35..c609d03a 100644 --- a/src/X.PagedList/IPagedList.cs +++ b/src/X.PagedList/IPagedList.cs @@ -1,5 +1,4 @@ -using System; -using JetBrains.Annotations; +using JetBrains.Annotations; using System.Collections.Generic; namespace X.PagedList; From 6242066c7d460ee3e6d1482b5739129c90f91823 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 17:18:56 +0300 Subject: [PATCH 15/19] Cleanup code --- src/X.PagedList/BasePagedList.cs | 34 +++++++++++++------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/X.PagedList/BasePagedList.cs b/src/X.PagedList/BasePagedList.cs index c78bfc01..5a1610fe 100644 --- a/src/X.PagedList/BasePagedList.cs +++ b/src/X.PagedList/BasePagedList.cs @@ -24,42 +24,42 @@ public abstract class BasePagedList : IPagedList protected List Subset = new(); /// - /// Total number of subsets within the superset. + /// Total number of subsets within the superset. /// /// - /// Total number of subsets within the superset. + /// Total number of subsets within the superset. /// public int PageCount => TotalItemCount > 0 ? (int)Math.Ceiling(TotalItemCount / (double)PageSize) : 0; /// - /// Total number of objects contained within the superset. + /// Total number of objects contained within the superset. /// /// - /// Total number of objects contained within the superset. + /// Total number of objects contained within the superset. /// public int TotalItemCount { get; protected set; } /// - /// 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. /// /// - /// 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. /// public int PageNumber { get; protected set; } /// - /// Maximum size any individual subset. + /// Maximum size any individual subset. /// /// - /// Maximum size any individual subset. + /// Maximum size any individual subset. /// public int PageSize { 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 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. /// /// - /// 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. /// public bool HasPreviousPage => PageCount > 0 && PageNumber <= PageCount && PageNumber > 1; @@ -163,22 +163,16 @@ protected internal BasePagedList(int pageNumber, int pageSize, int totalItemCoun } /// - /// Returns an enumerator that iterates through the BasePagedList<T>. + /// Returns an enumerator that iterates through the BasePagedList<T>. /// /// A BasePagedList<T>.Enumerator for the BasePagedList<T>. - public IEnumerator GetEnumerator() - { - return Subset.GetEnumerator(); - } + public IEnumerator GetEnumerator() => Subset.GetEnumerator(); /// - /// Returns an enumerator that iterates through the BasePagedList<T>. + /// Returns an enumerator that iterates through the BasePagedList<T>. /// /// A BasePagedList<T>.Enumerator for the BasePagedList<T>. - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); /// /// Gets the element at the specified index. From 32b1f3e628876f143d246e3e9bd6296bf4040185 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Sat, 13 Jul 2024 17:20:20 +0300 Subject: [PATCH 16/19] Fix merge issue --- src/X.PagedList/IPagedList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/X.PagedList/IPagedList.cs b/src/X.PagedList/IPagedList.cs index a30891a8..063ed2e8 100644 --- a/src/X.PagedList/IPagedList.cs +++ b/src/X.PagedList/IPagedList.cs @@ -22,7 +22,7 @@ public interface IPagedList : IPagedList, IReadOnlyList /// ///A non-enumerable copy of this paged list. [Obsolete("This method will be removed in future versions")] - PagedListMetaData GetMetaData(); + IPagedList GetMetaData(); } /// From 758a863e26eceb868120c68513f705cc3eee3506 Mon Sep 17 00:00:00 2001 From: Andrew Gubskiy Date: Thu, 1 Aug 2024 17:18:33 +0300 Subject: [PATCH 17/19] Fix project configuration --- src/X.Extensions.PagedList.EF/X.Extensions.PagedList.EF.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/X.Extensions.PagedList.EF/X.Extensions.PagedList.EF.csproj b/src/X.Extensions.PagedList.EF/X.Extensions.PagedList.EF.csproj index e151faf2..534f54ee 100644 --- a/src/X.Extensions.PagedList.EF/X.Extensions.PagedList.EF.csproj +++ b/src/X.Extensions.PagedList.EF/X.Extensions.PagedList.EF.csproj @@ -24,7 +24,7 @@ - + From c8fee6991f382458554eba7318a081bf7cc4c021 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 20 Sep 2024 22:26:30 +0300 Subject: [PATCH 18/19] Update workflow --- .github/workflows/build.yml | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49dba279..41ccca96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,29 +57,21 @@ jobs: -r ${{ matrix.BuildRuntime }} --self-contained - - name: Restore X.Extensions.PagedList.EF + - name: Restore X.PagedList.EF run: >- - dotnet restore src/X.Extensions.PagedList.EF/X.Extensions.PagedList.EF.csproj + dotnet restore src/X.PagedList.EF/X.PagedList.EF.csproj -r ${{ matrix.BuildRuntime }} -v minimal - - name: Build X.Extensions.PagedList.EF + - name: Restore X.PagedList.Mvc.Core run: >- - dotnet build src/X.Extensions.PagedList.EF/X.Extensions.PagedList.EF.csproj - --no-restore - -c ${{ env.BuildConfiguration }} - -r ${{ matrix.BuildRuntime }} - --self-contained - - - name: Restore X.Web.PagedList - run: >- - dotnet restore src/X.Web.PagedList/X.Web.PagedList.csproj + dotnet restore src/X.PagedList.Mvc.Core/X.PagedList.Mvc.Core.csproj -r ${{ matrix.BuildRuntime }} -v minimal - - name: Build X.Web.PagedList + - name: Build X.PagedList.Mvc.Core run: >- - dotnet build src/X.Web.PagedList/X.Web.PagedList.csproj + dotnet build src/X.PagedList.Mvc.Core/X.PagedList.Mvc.Core.csproj --no-restore -c ${{ env.BuildConfiguration }} -r ${{ matrix.BuildRuntime }} From 1ffe903538ad7ba1db0c7b7a248a6ed11290c811 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 12 Oct 2024 23:14:31 +0300 Subject: [PATCH 19/19] Fix conflicts --- examples/Example.DAL/Example.DAL.csproj | 10 +++--- .../Example.Website/Example.Website.csproj | 14 ++++---- src/X.PagedList.EF/X.PagedList.EF.csproj | 2 -- .../X.PagedList.Mvc.Core.csproj | 2 +- src/X.PagedList/X.PagedList.csproj | 6 ++-- .../X.PagedList.Tests.csproj | 32 +++++++++---------- 6 files changed, 32 insertions(+), 34 deletions(-) diff --git a/examples/Example.DAL/Example.DAL.csproj b/examples/Example.DAL/Example.DAL.csproj index 8e2a51f9..b906ade0 100644 --- a/examples/Example.DAL/Example.DAL.csproj +++ b/examples/Example.DAL/Example.DAL.csproj @@ -8,11 +8,11 @@ - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + diff --git a/examples/Example.Website/Example.Website.csproj b/examples/Example.Website/Example.Website.csproj index 325ef8b0..ceace9ad 100644 --- a/examples/Example.Website/Example.Website.csproj +++ b/examples/Example.Website/Example.Website.csproj @@ -6,21 +6,21 @@ - + - + - - - + + + - <_ContentIncludedByDefault Remove="Areas\Internal\Views\Shared\Paging\_Pager.cshtml" /> - <_ContentIncludedByDefault Remove="Areas\Internal\Views\Shared\Paging\_Pager_85.cshtml" /> + <_ContentIncludedByDefault Remove="Areas\Internal\Views\Shared\Paging\_Pager.cshtml"/> + <_ContentIncludedByDefault Remove="Areas\Internal\Views\Shared\Paging\_Pager_85.cshtml"/> diff --git a/src/X.PagedList.EF/X.PagedList.EF.csproj b/src/X.PagedList.EF/X.PagedList.EF.csproj index 81a30f31..ee787014 100644 --- a/src/X.PagedList.EF/X.PagedList.EF.csproj +++ b/src/X.PagedList.EF/X.PagedList.EF.csproj @@ -18,8 +18,6 @@ - - diff --git a/src/X.PagedList.Mvc.Core/X.PagedList.Mvc.Core.csproj b/src/X.PagedList.Mvc.Core/X.PagedList.Mvc.Core.csproj index 172c29a9..e7e7df10 100644 --- a/src/X.PagedList.Mvc.Core/X.PagedList.Mvc.Core.csproj +++ b/src/X.PagedList.Mvc.Core/X.PagedList.Mvc.Core.csproj @@ -6,7 +6,7 @@ default net6.0;net8.0 - + paging pagedlist paged list web mvc diff --git a/src/X.PagedList/X.PagedList.csproj b/src/X.PagedList/X.PagedList.csproj index ff726554..8454fbb5 100644 --- a/src/X.PagedList/X.PagedList.csproj +++ b/src/X.PagedList/X.PagedList.csproj @@ -11,12 +11,12 @@ - - + + - + diff --git a/tests/X.PagedList.Tests/X.PagedList.Tests.csproj b/tests/X.PagedList.Tests/X.PagedList.Tests.csproj index a00c5dda..98d81d4e 100644 --- a/tests/X.PagedList.Tests/X.PagedList.Tests.csproj +++ b/tests/X.PagedList.Tests/X.PagedList.Tests.csproj @@ -1,23 +1,23 @@  - - net6.0;net8.0 + + net6.0;net8.0 - enable - + enable + - - - - - - all - runtime; build; native; contentfiles; analyzers - - + + + + + + all + runtime; build; native; contentfiles; analyzers + + - - - + + +