zoukankan      html  css  js  c++  java
  • 改进的PageView

        public class PageView<T>
        {
            private ColumnTitle[] _columnTitles;
            public int RecordCount { get; }
            public IList<T> Items { get; }
            public int PageIndex { get; }
            public int PageSize { get; }
            public int PageCount { get; }

            public PageView(int pageSize, int pageIndex, IList<T> items, int recordCount)
            {
                Items = items ?? new List<T>();
                if (pageSize <= 0) throw new ArgumentOutOfRangeException(nameof(pageSize));
                if (pageIndex <= 0) throw new ArgumentOutOfRangeException(nameof(pageIndex));
                if (recordCount < 0) throw new ArgumentOutOfRangeException(nameof(recordCount));

                RecordCount = recordCount;
                PageCount = Convert.ToInt32(Math.Ceiling(recordCount * 1.0 / pageSize));
                PageIndex = pageIndex > PageCount ? PageCount : pageIndex;
                PageSize = pageSize;

            }

            /// <summary>
            /// 列标题
            /// </summary>
            public ColumnTitle[] ColumnTitles
            {
                get
                {
                    if (_columnTitles == null)
                    {
                        var type = typeof(T);
                        _columnTitles = type.GetColumnTitle();
                    }
                    return _columnTitles;
                }
            }
        }

  • 相关阅读:
    修改某路径下的文件名
    关于提取字符串中数字
    解决采集知乎数据时由于账号被封遗漏的账号重爬问题(python代码)
    project proposal写作框架
    PHP实现生成透明背景的PNG缩略图函数
    PHP中的绝对和相对路径解析
    js设置页面锚点
    列表顺序储存
    c++修饰符重载
    c++配置文件读取、修改、添加
  • 原文地址:https://www.cnblogs.com/nirvanan/p/11981605.html
Copyright © 2011-2022 走看看