From 985577b8206c36c3ee701cab6bc25a2a1bbcd423 Mon Sep 17 00:00:00 2001 From: Edi Wang Date: Thu, 31 Oct 2024 09:37:16 +0800 Subject: [PATCH] Refactor BasePagedList and remove PagedListMetaData BasePagedList no longer inherits from PagedListMetaData and now directly implements IPagedList. Added properties (PageCount, TotalItemCount, PageNumber, PageSize, HasPreviousPage, HasNextPage, IsFirstPage, IsLastPage) with protected set accessors to BasePagedList. Removed PagedListMetaData class. Added Subset list of type T to BasePagedList and initialized it as an empty list. --- src/Moonglade.Web/PagedList/BasePagedList.cs | 18 ++++++++++++++- .../PagedList/PagedListMetaData.cs | 23 ------------------- 2 files changed, 17 insertions(+), 24 deletions(-) delete mode 100644 src/Moonglade.Web/PagedList/PagedListMetaData.cs diff --git a/src/Moonglade.Web/PagedList/BasePagedList.cs b/src/Moonglade.Web/PagedList/BasePagedList.cs index 7e26cca67..da9bbb4bf 100644 --- a/src/Moonglade.Web/PagedList/BasePagedList.cs +++ b/src/Moonglade.Web/PagedList/BasePagedList.cs @@ -11,8 +11,24 @@ /// The type of object the collection should contain. /// /// -public class BasePagedList : PagedListMetaData, IPagedList +public class BasePagedList : IPagedList { + public int PageCount { get; protected set; } + + public int TotalItemCount { get; protected set; } + + public int PageNumber { get; protected set; } + + public int PageSize { get; protected set; } + + public bool HasPreviousPage { get; protected set; } + + public bool HasNextPage { get; protected set; } + + public bool IsFirstPage { get; protected set; } + + public bool IsLastPage { get; protected set; } + protected readonly List Subset = []; /// diff --git a/src/Moonglade.Web/PagedList/PagedListMetaData.cs b/src/Moonglade.Web/PagedList/PagedListMetaData.cs deleted file mode 100644 index 785114429..000000000 --- a/src/Moonglade.Web/PagedList/PagedListMetaData.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Moonglade.Web.PagedList; - -/// -/// Non-enumerable version of the PagedList class. -/// -public class PagedListMetaData : IPagedList -{ - public int PageCount { get; protected set; } - - public int TotalItemCount { get; protected set; } - - public int PageNumber { get; protected set; } - - public int PageSize { get; protected set; } - - public bool HasPreviousPage { get; protected set; } - - public bool HasNextPage { get; protected set; } - - public bool IsFirstPage { get; protected set; } - - public bool IsLastPage { get; protected set; } -} \ No newline at end of file