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

  • 相关阅读:
    Girls and Boys
    Kindergarten
    codevs 2822 爱在心中
    Popular Cows
    QWQ
    2488 绿豆蛙的归宿(拓扑+dp)
    P1119 灾后重建
    Mr. Frog’s Game
    Basic Data Structure
    A strange lift
  • 原文地址:https://www.cnblogs.com/nirvanan/p/11981605.html
Copyright © 2011-2022 走看看