Exemple #1
0
        /// <summary>
        /// Builds an item (and the link nested within it)
        /// </summary>
        /// <returns></returns>
        private HelperResult BuildItem(string text, int pageNumber, LinkType linkType)
        {
            // build the item model
            var linkModel = new RenderLinkModel();

            linkModel.PageNumber     = pageNumber;
            linkModel.CurrentPage    = _currentPage;
            linkModel.LinkType       = linkType;
            linkModel.LinkText       = text;
            linkModel.PageUrlBuilder = _pageUrlBuilder;

            switch (linkType)
            {
            case LinkType.First:
                linkModel.CssClass = _firstCssClass;
                break;

            case LinkType.Previous:
                linkModel.CssClass = _previousCssClass;
                break;

            case LinkType.Page:
                linkModel.CssClass = _pageCssClass;
                if (linkModel.Disabled)
                {
                    // it is disabled because it is selected and active!
                    linkModel.CssClass = (linkModel.CssClass + " " + _activeCssClass).Trim();
                }
                break;

            case LinkType.Next:
                linkModel.CssClass = _nextCssClass;
                break;

            case LinkType.Last:
                linkModel.CssClass = _lastCssClass;
                break;
            }

            if (linkModel.Disabled)
            {
                linkModel.CssClass = (linkModel.CssClass + " " + _disabledCssClass).Trim();
            }

            var itemModel = new RenderItemModel();

            itemModel.PageNumber  = pageNumber;
            itemModel.CurrentPage = _currentPage;
            itemModel.LinkType    = linkType;
            itemModel.CssClass    = linkModel.CssClass;
            itemModel.LinkRender  = new HelperResult(writer => writer.Write(_linkTemplate(linkModel)));

            return(_itemTemplate(itemModel));
        }
        /// <summary>
        /// Builds an item (and the link nested within it)
        /// </summary>
        /// <returns></returns>
        private HelperResult BuildItem(string text, int pageNumber, LinkType linkType)
        {
            // build the item model
            var linkModel = new RenderLinkModel();
            linkModel.PageNumber = pageNumber;
            linkModel.CurrentPage = _currentPage;
            linkModel.LinkType = linkType;
            linkModel.LinkText = text;
            linkModel.PageUrlBuilder = _pageUrlBuilder;

            switch (linkType)
            {
                case LinkType.First:
                    linkModel.CssClass = _firstCssClass;
                    break;
                case LinkType.Previous:
                    linkModel.CssClass = _previousCssClass;
                    break;
                case LinkType.Page:
                    linkModel.CssClass = _pageCssClass;
                    if (linkModel.Disabled)
                        // it is disabled because it is selected and active!
                        linkModel.CssClass = (linkModel.CssClass + " " + _activeCssClass).Trim();
                    break;
                case LinkType.Next:
                    linkModel.CssClass = _nextCssClass;
                    break;
                case LinkType.Last:
                    linkModel.CssClass = _lastCssClass;
                    break;
            }

            if (linkModel.Disabled)
                linkModel.CssClass = (linkModel.CssClass + " " + _disabledCssClass).Trim();

            var itemModel = new RenderItemModel();
            itemModel.PageNumber = pageNumber;
            itemModel.CurrentPage = _currentPage;
            itemModel.LinkType = linkType;
            itemModel.CssClass = linkModel.CssClass;
            itemModel.LinkRender = new HelperResult(writer => writer.Write(_linkTemplate(linkModel)));

            return _itemTemplate(itemModel);
        }