Pattern for exposing non-generic version of generic interface

后端 未结 3 1962
梦谈多话
梦谈多话 2021-01-31 09:44

Say I have the following interface for exposing a paged list

public interface IPagedList
{
    IEnumerable PageResults { get; }
    int Current         


        
3条回答
  •  忘了有多久
    2021-01-31 10:16

    One option is to create 2 interfaces such that:

        public interface IPagedListDetails
        {
            int CurrentPageIndex { get; }
            int TotalRecordCount { get; }
            int TotalPageCount { get; }
            int PageSize { get; }
        }
    
        public interface IPagedList : IPagedListDetails
        {
            IEnumerable PageResults { get; }
        }
    

    And then your control:

    public class PagedListPager(IPagedListDetails details)
    

提交回复
热议问题