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;
                }
            }
        }

  • 相关阅读:
    PHP中单引号与双引号的区别分析
    utf8_unicode_ci与utf8_general_ci的区别
    [mysql-Ver5.6.23] windows版my.ini配置
    Gateway/Worker模型 数据库使用示例
    php 字符串 以 开头 以结尾 startWith endWith
    MySQL错误ERROR 2002 (HY000): Can't connect to local MySQL server
    vim变ide
    在Vue中使用样式
    Vue指令之`v-model`和`双向数据绑定
    Vue指令之事件修饰符
  • 原文地址:https://www.cnblogs.com/nirvanan/p/11981605.html
Copyright © 2011-2022 走看看