答案 0 :(得分:0)
我不确定我是否有_delegateCommand
权利的目的 - 我想它应该是返回IEnumerable<TItem>
的函数。如果是这样,那么你可以像那样声明它,然后你不必引入另一个通用参数:
public class Page<TItem>
{
private Func<IEnumerable<TItem>>_delegateCommand;
public int CurrentPage { get; }
public int TotalPages { get; }
public int PageItemsCount { get; }
public int TotalItemsCount { get; }
public IEnumerable<TItem> Items { get; }
public Page(int page, int totalPages, int itemsCount,
int totalItemsCount, IEnumerable<TItem> items,
Func<IEnumerable<TItem>> delegateCommand)
{
CurrentPage = page;
TotalPages = totalPages;
PageItemsCount = itemsCount;
TotalItemsCount = totalItemsCount;
Items = items;
_delegateCommand = delegateCommand;
}
public bool HasNext()
{
return CurrentPage <= TotalPages;
}
public bool HasPrevious()
{
return CurrentPage >= 1;
}
}