コード例 #1
0
ファイル: PagingResult.cs プロジェクト: Webalap/W-ALAP
        private PagingResult(PagingParams pagingParams, int recordCount, int totalRecordCount)
        {
            if (pagingParams == null)
            {
                throw new ArgumentNullException("pagingParams");
            }

            _pagingParams = pagingParams;


            int pageNumber = _pagingParams.PageNumber;
            int pageSize   = _pagingParams.PageSize;


            if (totalRecordCount < 1)
            {
                throw new ArgumentOutOfRangeException("totalRecordCount", totalRecordCount, "Argument must be greater than zero.");
            }

            if (recordCount < 1)
            {
                throw new ArgumentOutOfRangeException("recordCount", recordCount, "Argument must be greater than or equal to zero.");
            }

            if (recordCount > pageSize)
            {
                throw new ArgumentOutOfRangeException("recordCount", recordCount, "Argument must be less than or equal to page size.");
            }

            if (recordCount > totalRecordCount)
            {
                throw new ArgumentOutOfRangeException("recordCount", "Argument cannot be greater than 'totalRecordCount'.");
            }


            _recordCount      = recordCount;
            _totalRecordCount = totalRecordCount;

            _firstRecordNum = ((pageNumber - 1) * pageSize) + 1;

            _lastRecordNum = _firstRecordNum + _recordCount - 1;


            if (_firstRecordNum > _totalRecordCount)
            {
                throw new ApplicationException("'_firstRecordNum' cannot be greater than 'totalRecordCount'.");
            }

            if (_lastRecordNum > _totalRecordCount)
            {
                throw new ApplicationException("'_lastRecordNum' cannot be greater than 'totalRecordCount'.");
            }
        }
コード例 #2
0
ファイル: PagingResult.cs プロジェクト: Webalap/W-ALAP
        public static PagingResult Create(PagingParams pagingParams, int recordCount, int totalRecordCount)
        {
            Contract.Requires(recordCount >= 0);
            Contract.Requires(totalRecordCount >= 0);

            if (totalRecordCount < 1)
            {
                return(new PagingResult(pagingParams));
            }
            else
            {
                return(new PagingResult(pagingParams, recordCount, totalRecordCount));
            }
        }
コード例 #3
0
ファイル: PagingResult.cs プロジェクト: Webalap/W-ALAP
        private PagingResult(PagingParams pagingParams)
        {
            if (pagingParams == null)
            {
                throw new ArgumentNullException("pagingParams");
            }


            _pagingParams     = pagingParams;
            _recordCount      = 0;
            _totalRecordCount = 0;

            _firstRecordNum = 0;
            _lastRecordNum  = 0;
        }
コード例 #4
0
ファイル: PagingResult.cs プロジェクト: Webalap/W-ALAP
        public bool Equals(PagingResult other)
        {
            if (Object.ReferenceEquals(other, null))
            {
                return(false);
            }
            if (Object.ReferenceEquals(other, this))
            {
                return(true);
            }


            if (!PagingParams.Equals(other.PagingParams))
            {
                return(false);
            }

            if (RecordCount != other.RecordCount)
            {
                return(false);
            }
            if (TotalRecordCount != other.TotalRecordCount)
            {
                return(false);
            }
            if (FirstRecordNum != other.FirstRecordNum)
            {
                return(false);
            }
            if (LastRecordNum != other.LastRecordNum)
            {
                return(false);
            }

            return(true);
        }