コード例 #1
0
		/// <summary>
		///     Get a value that indicates whether the current pager item should be disabled.
		/// </summary>
		/// <param name="context">The pager item generation context.</param>
		/// <returns>If the current pager item should be disabled, returns <c>true</c>; otherwise returns <c>false</c>.</returns>
		private bool ItemShouldBeDisabled(PagerItemGenerationContext context)
		{
			switch (context.PagerItem.ItemType)
			{
				case PagerItemType.First:
				case PagerItemType.Last:
					switch (context.PagerItemOptions.ActiveMode)
					{
						case FirstAndLastPagerItemActiveMode.Always:
							return false;
						case FirstAndLastPagerItemActiveMode.NotInCurrentPage:
							return context.CurrentPage == context.PagerItem.PageNumber;
						case FirstAndLastPagerItemActiveMode.NotInVisiblePageList:
							return IsPageVisible(context);
						default:
							throw new InvalidOperationException(
								$"The value of '{nameof(context.PagerItemOptions.ActiveMode)}' property cannot be a valid enum item for a pager item of type '{context.PagerItem.ItemType}'.");
					}
				case PagerItemType.Next:
					return context.CurrentPage == context.TotalPage;
				case PagerItemType.Previous:
					return context.CurrentPage == 1;
				default:
					return false;
			}
		}
コード例 #2
0
		/// <summary>
		///     Get the rendering state of the current pager item.
		/// </summary>
		/// <param name="context">The pager item generation context.</param>
		/// <returns>The rendering item of the current pager item.</returns>
		private PagerRenderingItemState GetRenderingItemState(PagerItemGenerationContext context)
		{
			switch (context.PagerItem.ItemType)
			{
				case PagerItemType.First:
				case PagerItemType.Last:
				case PagerItemType.Previous:
				case PagerItemType.Next:
					var disabled = ItemShouldBeDisabled(context);
					if (!disabled)
					{
						return PagerRenderingItemState.Normal;
					}
					switch (context.PagerItemOptions.InactiveBehavior)
					{
						case SpecialPagerItemInactiveBehavior.Disable:
							return PagerRenderingItemState.Disabled;
						case SpecialPagerItemInactiveBehavior.Hide:
							return PagerRenderingItemState.Hidden;
						default:
							throw new InvalidOperationException(
								$"The value of '{nameof(context.PagerItemOptions.InactiveBehavior)}' property cannot be a valid enum item for a pager item of type '{context.PagerItem.ItemType}'.");
					}
				case PagerItemType.Current:
					return PagerRenderingItemState.Active;
				default:
					return PagerRenderingItemState.Normal;
			}
		}
コード例 #3
0
        /// <summary>
        ///     Generate a <see cref="PagerRenderingList" /> for a series of <see cref="PagerItem" />.
        /// </summary>
        /// <param name="items">The collection of <see cref="PagerItem" /> which are included in the list.</param>
        /// <param name="context">The generation context.</param>
        /// <returns>The generated <see cref="PagerRenderingList" /> instance.</returns>
        private PagerRenderingList GenerateRenderingListCore(IEnumerable <PagerItem> items, PagerGenerationContext context)
        {
            var optionsCache = new Dictionary <PagerItemType, PagerItemOptions>();

            var renderingItemList = new List <PagerRenderingItem>();

            // Owner
            var result = new PagerRenderingList
            {
                Settings = new Dictionary <string, string>(context.Options.AdditionalSettings)
            };

            foreach (var item in items)
            {
                PagerItemOptions itemOptions;

                // Try to get cached options, or create a new option instance
                if (!optionsCache.TryGetValue(item.ItemType, out itemOptions))
                {
                    itemOptions = context.Options.ItemOptions.GetMergedOptionsFor(item);
                    optionsCache[item.ItemType] = itemOptions;
                }

                // Generate item context
                var itemContext = new PagerItemGenerationContext(context, item, itemOptions);

                // Generate item and add to list
                var renderingItem = GenerateRenderingItem(result, itemContext);
                renderingItemList.Add(renderingItem);
            }

            // Result
            result.Items = new ReadOnlyCollection <PagerRenderingItem>(renderingItemList);
            return(result);
        }
コード例 #4
0
        /// <summary>
        ///     Get a value that indicates whether the current pager item should be disabled.
        /// </summary>
        /// <param name="context">The pager item generation context.</param>
        /// <returns>If the current pager item should be disabled, returns <c>true</c>; otherwise returns <c>false</c>.</returns>
        private bool ItemShouldBeDisabled(PagerItemGenerationContext context)
        {
            switch (context.PagerItem.ItemType)
            {
            case PagerItemType.First:
            case PagerItemType.Last:
                switch (context.PagerItemOptions.ActiveMode)
                {
                case FirstAndLastPagerItemActiveMode.Always:
                    return(false);

                case FirstAndLastPagerItemActiveMode.NotInCurrentPage:
                    return(context.CurrentPage == context.PagerItem.PageNumber);

                case FirstAndLastPagerItemActiveMode.NotInVisiblePageList:
                    return(IsPageVisible(context));

                default:
                    throw new InvalidOperationException(
                              $"The value of '{nameof(context.PagerItemOptions.ActiveMode)}' property cannot be a valid enum item for a pager item of type '{context.PagerItem.ItemType}'.");
                }

            case PagerItemType.Next:
                return(context.CurrentPage == context.TotalPage);

            case PagerItemType.Previous:
                return(context.CurrentPage == 1);

            default:
                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        ///     Get the rendering state of the current pager item.
        /// </summary>
        /// <param name="context">The pager item generation context.</param>
        /// <returns>The rendering item of the current pager item.</returns>
        private PagerRenderingItemState GetRenderingItemState(PagerItemGenerationContext context)
        {
            switch (context.PagerItem.ItemType)
            {
            case PagerItemType.First:
            case PagerItemType.Last:
            case PagerItemType.Previous:
            case PagerItemType.Next:
                var disabled = ItemShouldBeDisabled(context);
                if (!disabled)
                {
                    return(PagerRenderingItemState.Normal);
                }
                switch (context.PagerItemOptions.InactiveBehavior)
                {
                case SpecialPagerItemInactiveBehavior.Disable:
                    return(PagerRenderingItemState.Disabled);

                case SpecialPagerItemInactiveBehavior.Hide:
                    return(PagerRenderingItemState.Hidden);

                default:
                    throw new InvalidOperationException(
                              $"The value of '{nameof(context.PagerItemOptions.InactiveBehavior)}' property cannot be a valid enum item for a pager item of type '{context.PagerItem.ItemType}'.");
                }

            case PagerItemType.Current:
                return(PagerRenderingItemState.Active);

            default:
                return(PagerRenderingItemState.Normal);
            }
        }
コード例 #6
0
		/// <summary>
		///     Determine if the page is in visible page number list.
		/// </summary>
		/// <param name="context">
		///     The <see cref="PagerItemGenerationContext" /> which contains all informations for the pager and
		///     current page.
		/// </param>
		/// <returns>If the current pager item is in the visible list, returns <c>true</c>; otherwise, returns <c>false</c>.</returns>
		private static bool IsPageVisible(PagerItemGenerationContext context)
		{
			var number = context.PagerItem.PageNumber;
			return number <= context.Options.PagerItemsForEndings
			       || number >= context.TotalPage - context.Options.PagerItemsForEndings + 1
			       || number >= context.CurrentPage - context.Options.ExpandPageItemsForCurrentPage
			       || number <= context.CurrentPage + context.Options.ExpandPageItemsForCurrentPage;
		}
コード例 #7
0
        /// <summary>
        ///     The core method for handling the current uri.
        /// </summary>
        /// <param name="currentUri">The URL to handle, this URL is ensured in absolute mode.</param>
        /// <param name="context">The generation context.</param>
        /// <returns>The generated URL string.</returns>
        /// <remarks>
        ///     Most URI handling method requirest the URI be absolute format, however in the view page relative URI is
        ///     recommended. The <paramref name="currentUri" /> argument in this method has been handled and is ensured to be
        ///     absolute. The generator will correctly recover it to the original format after handling.
        /// </remarks>
        protected override Uri HandleUriCore(Uri currentUri, PagerItemGenerationContext context)
        {
            // Get name and value
            var name  = GenerateQueryParameterName(context);
            var value = GenerateQueryParameterValue(context);

            // Generate result
            return(ChangeQueryParameterValue(currentUri, name, value));
        }
コード例 #8
0
        /// <summary>
        ///     Determine if the page is in visible page number list.
        /// </summary>
        /// <param name="context">
        ///     The <see cref="PagerItemGenerationContext" /> which contains all informations for the pager and
        ///     current page.
        /// </param>
        /// <returns>If the current pager item is in the visible list, returns <c>true</c>; otherwise, returns <c>false</c>.</returns>
        private static bool IsPageVisible(PagerItemGenerationContext context)
        {
            var number = context.PagerItem.PageNumber;

            return(number <= context.Options.PagerItemsForEndings ||
                   number >= context.TotalPage - context.Options.PagerItemsForEndings + 1 ||
                   number >= context.CurrentPage - context.Options.ExpandPageItemsForCurrentPage ||
                   number <= context.CurrentPage + context.Options.ExpandPageItemsForCurrentPage);
        }
コード例 #9
0
        /// <summary>
        ///     The core method for handling the current uri.
        /// </summary>
        /// <param name="currentUri">The URL to handle, this URL is ensured in absolute mode.</param>
        /// <param name="context">The generation context.</param>
        /// <returns></returns>
        /// <remarks>
        ///     Most URI handling method requirest the URI be absolute format, however in the view page relative URI is
        ///     recommended. The <paramref name="currentUri" /> argument in this method has been handled and is ensured to be
        ///     absolute. The generator will correctly recover it to the original format after handling.
        /// </remarks>
        protected override Uri HandleUriCore(Uri currentUri, PagerItemGenerationContext context)
        {
            // Create URI and change fragment
            var uriBuilder = new UriBuilder(currentUri)
            {
                Fragment = GenerateFragment(context)
            };

            return(uriBuilder.Uri);
        }
コード例 #10
0
		/// <summary>
		///     The core method for handling the current uri.
		/// </summary>
		/// <param name="currentUri">The URL to handle, this URL is ensured in absolute mode.</param>
		/// <param name="context">The generation context.</param>
		/// <returns></returns>
		/// <remarks>
		///     Most URI handling method requirest the URI be absolute format, however in the view page relative URI is
		///     recommended. The <paramref name="currentUri" /> argument in this method has been handled and is ensured to be
		///     absolute. The generator will correctly recover it to the original format after handling.
		/// </remarks>
		protected override string HandleUriCore(string currentUri, PagerItemGenerationContext context)
		{
			// Create URI and change fragment
			var uriBuilder = new UriBuilder(currentUri)
			{
				Fragment = GenerateFragment(context)
			};

			return uriBuilder.ToString();
		}
コード例 #11
0
 /// <summary>
 ///     Generate a <see cref="PagerRenderingItem" /> for the current pager item.
 /// </summary>
 /// <param name="list">The ownner list of the new item.</param>
 /// <param name="context">The generation context.</param>
 /// <returns>The generated <see cref="PagerRenderingItem" /> instance.</returns>
 private PagerRenderingItem GenerateRenderingItem(PagerRenderingList list, PagerItemGenerationContext context)
 {
     return(new PagerRenderingItem(list)
     {
         Content = context.PagerItemOptions.Content?.GenerateContent(context),
         Link = context.PagerItemOptions.Link?.GenerateLink(context),
         Settings = new Dictionary <string, string>(context.PagerItemOptions.AdditionalSettings),
         State = GetRenderingItemState(context)
     });
 }
コード例 #12
0
        /// <summary>
        ///     The core method for handling the current uri.
        /// </summary>
        /// <param name="currentUri">The URL to handle, this URL is ensured in absolute mode.</param>
        /// <param name="context">The generation context.</param>
        /// <returns>The generated URL string.</returns>
        /// <remarks>
        ///     Most URI handling method requirest the URI be absolute format, however in the view page relative URI is
        ///     recommended. The <paramref name="currentUri" /> argument in this method has been handled and is ensured to be
        ///     absolute. The generator will correctly recover it to the original format after handling.
        /// </remarks>
        protected override string HandleUriCore(string currentUri, PagerItemGenerationContext context)
        {
            // Get name and value
            var name  = GenerateQueryParameterName(context);
            var value = GenerateQueryParameterValue(context);

            // Get base uri
            var baseUri = GetCurrentUriWithQuery(context.ViewContext);

            // Generate result
            return(ChangeQueryParameterValue(baseUri, name, value));
        }
コード例 #13
0
        public string GenerateLink(PagerItemGenerationContext context)
        {
            var baseUri = GetRealBaseUri(context.ViewContext);

            // Hosted uri for API compatibility
            var hostedUri = new Uri("http://test.local/");

            // Generate uri object
            var uri = new Uri(baseUri, UriKind.RelativeOrAbsolute);

            // Start with slash detection.
            var isStartWithSlash = false;

            // If the uri is not absolute uri, convert it to an absolute one
            var isAbsolute = uri.IsAbsoluteUri;

            if (!isAbsolute)
            {
                isStartWithSlash = !string.IsNullOrEmpty(baseUri) && baseUri[0] == '/';
                uri = new Uri(hostedUri, uri);
            }

            // Core method to handle URI.
            var finalUri = HandleUriCore(uri, context);

            // If the original uri is not absolute, remove the hosted part
            if (!isAbsolute)
            {
                finalUri = hostedUri.MakeRelativeUri(finalUri);
            }

            var result = UriHelper.Encode(finalUri);

            // Add start slash if necessary
            if (!isAbsolute && isStartWithSlash)
            {
                result = "/" + result;
            }

            return(result);
        }
コード例 #14
0
 /// <summary>
 ///     The core method for handling the base uri.
 /// </summary>
 /// <param name="baseUri">The URL to handle, this URL is ensured in absolute mode.</param>
 /// <param name="context">The generation context.</param>
 /// <returns></returns>
 /// <remarks>
 ///     Most URI handling method requires the URI be absolute format, however in the view page relative URI is
 ///     recommended. The <paramref name="baseUri" /> argument in this method has been handled and is ensured to be
 ///     absolute. The generator will correctly recover it to the original format after handling.
 /// </remarks>
 protected abstract Uri HandleUriCore([NotNull] Uri baseUri, [NotNull] PagerItemGenerationContext context);
コード例 #15
0
 /// <summary>
 ///     Generate the link url for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 public string GenerateLink(PagerItemGenerationContext context)
 {
     return(LinkGenerator(context));
 }
コード例 #16
0
 /// <summary>
 ///     When be derived, generate the content string.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The generated content string.</returns>
 protected override string GenerateContentString(PagerItemGenerationContext context)
 => string.Format(FormatProvider, Format, context.PagerItem.PageNumber);
コード例 #17
0
 /// <summary>
 ///     Generate the query parameter value for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The query parameter name for current pager item.</returns>
 public override string GenerateQueryParameterValue(PagerItemGenerationContext context)
 {
     return(QueryValueGenerator(context));
 }
コード例 #18
0
		/// <summary>
		///     When derived, generate the query parameter value for the specified <see cref="PagerItem" />.
		/// </summary>
		/// <param name="context">The generation context.</param>
		/// <returns>The query parameter name for current pager item.</returns>
		public override string GenerateQueryParameterValue(PagerItemGenerationContext context) => QueryValueGenerator(context);
コード例 #19
0
		/// <summary>
		///     When be derived, generate the content string.
		/// </summary>
		/// <param name="context">The generation context.</param>
		/// <returns>The generated content string.</returns>
		protected override string GenerateContentString(PagerItemGenerationContext context)
			=> string.Format(FormatProvider, Format, context.PagerItem.PageNumber);
コード例 #20
0
 /// <summary>
 ///     Generate the link url for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 public string GenerateLink(PagerItemGenerationContext context) => LinkGenerator(context);
コード例 #21
0
 /// <summary>
 ///     Generate the link url for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 public string GenerateLink(PagerItemGenerationContext context)
 {
     return(Text);
 }
コード例 #22
0
 /// <summary>
 ///     When derived, generate the query parameter name for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The query parameter name for current pager item.</returns>
 public override string GenerateQueryParameterName(PagerItemGenerationContext context)
 {
     return(QueryParameterName);
 }
コード例 #23
0
		/// <summary>
		///     Generate the query parameter value for the specified <see cref="PagerItem" />.
		/// </summary>
		/// <param name="context">The generation context.</param>
		/// <returns>The query parameter name for current pager item.</returns>
		public override string GenerateQueryParameterValue(PagerItemGenerationContext context)
			=> string.Format(FormatProvider, Format, context.PagerItem.PageNumber);
コード例 #24
0
		/// <summary>
		///     When be derived, generate the content string.
		/// </summary>
		/// <param name="context">The generation context.</param>
		/// <returns>The generated content string.</returns>
		protected abstract string GenerateContentString(PagerItemGenerationContext context);
コード例 #25
0
		/// <summary>
		///     Generate the content for a specified pager item.
		/// </summary>
		/// <param name="context">The generation context.</param>
		/// <returns>The generated HTML content for the pager item.</returns>
		public IHtmlContent GenerateContent(PagerItemGenerationContext context)
			=> GenerateContentString(context).ToHtmlContent(EncodeText);
コード例 #26
0
 /// <summary>
 ///     When be derived, generate the content string.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The generated content string.</returns>
 protected abstract string GenerateContentString(PagerItemGenerationContext context);
コード例 #27
0
 /// <summary>
 ///     Generate the content for a specified pager item.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The generated HTML content for the pager item.</returns>
 public IHtmlContent GenerateContent(PagerItemGenerationContext context)
 => GenerateContentString(context).ToHtmlContent(EncodeText);
コード例 #28
0
 /// <summary>
 ///     Generate the content string.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The generated content string.</returns>
 protected override string GenerateContentString(PagerItemGenerationContext context)
 {
     return(StringContentGenerator(context));
 }
コード例 #29
0
 /// <summary>
 ///     Generate the content for a specified pager item.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The generated HTML content for the pager item.</returns>
 public IHtmlContent GenerateContent(PagerItemGenerationContext context) => HtmlContentGenerator(context);
コード例 #30
0
 /// <summary>
 ///     Generate the query parameter value for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The query parameter name for current pager item.</returns>
 public override string GenerateQueryParameterValue(PagerItemGenerationContext context)
 => string.Format(FormatProvider, Format, context.PagerItem.PageNumber);
コード例 #31
0
 /// <summary>
 ///     Generate the content string.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The generated content string.</returns>
 protected override string GenerateContentString(PagerItemGenerationContext context)
 => StringContentGenerator(context);
コード例 #32
0
		/// <summary>
		///     Generate the link url for the specified <see cref="PagerItem" />.
		/// </summary>
		/// <param name="context">The generation context.</param>
		public string GenerateLink(PagerItemGenerationContext context)
		{
			var currentUri = GetCurrentUriWithQuery(context.ViewContext);
			return HandleUriCore(currentUri, context);
		}
コード例 #33
0
		/// <summary>
		///     Generate the link url for the specified <see cref="PagerItem" />.
		/// </summary>
		/// <param name="context">The generation context.</param>
		public string GenerateLink(PagerItemGenerationContext context)
			=> string.Format(FormatProvider, Format, context.PagerItem.PageNumber);
コード例 #34
0
 /// <summary>
 ///     When derived, generate the query parameter value for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The query parameter name for current pager item.</returns>
 public abstract string GenerateQueryParameterValue([NotNull] PagerItemGenerationContext context);
コード例 #35
0
		/// <summary>
		///     Generate the link url for the specified <see cref="PagerItem" />.
		/// </summary>
		/// <param name="context">The generation context.</param>
		public string GenerateLink(PagerItemGenerationContext context) => LinkGenerator(context);
コード例 #36
0
 /// <summary>
 ///     The core method for handling the current uri.
 /// </summary>
 /// <param name="currentUri">The URL to handle, this URL is ensured in absolute mode.</param>
 /// <param name="context">The generation context.</param>
 /// <returns></returns>
 /// <remarks>
 ///     Most URI handling method requirest the URI be absolute format, however in the view page relative URI is
 ///     recommended. The <paramref name="currentUri" /> argument in this method has been handled and is ensured to be
 ///     absolute. The generator will correctly recover it to the original format after handling.
 /// </remarks>
 protected abstract string HandleUriCore([NotNull] string currentUri, [NotNull] PagerItemGenerationContext context);
コード例 #37
0
 /// <summary>
 ///     When derived, generate the query parameter name for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The query parameter name for current pager item.</returns>
 public override string GenerateQueryParameterName(PagerItemGenerationContext context) => QueryParameterName;
コード例 #38
0
		/// <summary>
		///     The core method for handling the current uri.
		/// </summary>
		/// <param name="currentUri">The URL to handle, this URL is ensured in absolute mode.</param>
		/// <param name="context">The generation context.</param>
		/// <returns>The generated URL string.</returns>
		/// <remarks>
		///     Most URI handling method requirest the URI be absolute format, however in the view page relative URI is
		///     recommended. The <paramref name="currentUri" /> argument in this method has been handled and is ensured to be
		///     absolute. The generator will correctly recover it to the original format after handling.
		/// </remarks>
		protected override string HandleUriCore(string currentUri, PagerItemGenerationContext context)
		{
			// Get name and value
			var name = GenerateQueryParameterName(context);
			var value = GenerateQueryParameterValue(context);

			// Get base uri
			var baseUri = GetCurrentUriWithQuery(context.ViewContext);

			// Generate result
			return ChangeQueryParameterValue(baseUri, name, value);
		}
コード例 #39
0
 /// <summary>
 ///     When derived, generate the fragment part for a specified pager item.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns></returns>
 protected abstract string GenerateFragment([NotNull] PagerItemGenerationContext context);
コード例 #40
0
 /// <summary>
 ///     Generate the link url for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 public string GenerateLink(PagerItemGenerationContext context)
 {
     return(string.Format(FormatProvider, Format, context.PagerItem.PageNumber));
 }
コード例 #41
0
        /// <summary>
        ///     Generate the link url for the specified <see cref="PagerItem" />.
        /// </summary>
        /// <param name="context">The generation context.</param>
        public string GenerateLink(PagerItemGenerationContext context)
        {
            var currentUri = GetCurrentUriWithQuery(context.ViewContext);

            return(HandleUriCore(currentUri, context));
        }
コード例 #42
0
		/// <summary>
		///     Generate a <see cref="PagerRenderingItem" /> for the current pager item.
		/// </summary>
		/// <param name="list">The ownner list of the new item.</param>
		/// <param name="context">The generation context.</param>
		/// <returns>The generated <see cref="PagerRenderingItem" /> instance.</returns>
		private PagerRenderingItem GenerateRenderingItem(PagerRenderingList list, PagerItemGenerationContext context)
		{
			return new PagerRenderingItem(list)
			{
				Content = context.PagerItemOptions.Content?.GenerateContent(context),
				Link = context.PagerItemOptions.Link?.GenerateLink(context),
				Settings = new Dictionary<string, string>(context.PagerItemOptions.AdditionalSettings),
				State = GetRenderingItemState(context)
			};
		}
コード例 #43
0
 /// <summary>
 ///     Generate the link url for the specified <see cref="PagerItem" />.
 /// </summary>
 /// <param name="context">The generation context.</param>
 public string GenerateLink(PagerItemGenerationContext context) => Text;
コード例 #44
0
		/// <summary>
		///     Generate the content string.
		/// </summary>
		/// <param name="context">The generation context.</param>
		/// <returns>The generated content string.</returns>
		protected override string GenerateContentString(PagerItemGenerationContext context)
			=> StringContentGenerator(context);
コード例 #45
0
 /// <summary>
 ///     Generate the content for a specified pager item.
 /// </summary>
 /// <param name="context">The generation context.</param>
 /// <returns>The generated HTML content for the pager item.</returns>
 public IHtmlContent GenerateContent(PagerItemGenerationContext context)
 {
     return(HtmlContentGenerator(context));
 }
コード例 #46
0
		/// <summary>
		///     Generate a <see cref="PagerRenderingList" /> for a series of <see cref="PagerItem" />.
		/// </summary>
		/// <param name="items">The collection of <see cref="PagerItem" /> which are included in the list.</param>
		/// <param name="context">The generation context.</param>
		/// <returns>The generated <see cref="PagerRenderingList" /> instance.</returns>
		private PagerRenderingList GenerateRenderingListCore(IEnumerable<PagerItem> items, PagerGenerationContext context)
		{
			var optionsCache = new Dictionary<PagerItemType, PagerItemOptions>();

			var renderingItemList = new List<PagerRenderingItem>();

			// Owner
			var result = new PagerRenderingList
			{
				Settings = new Dictionary<string, string>(context.Options.AdditionalSettings)
			};

			foreach (var item in items)
			{
				PagerItemOptions itemOptions;

				// Try to get cached options, or create a new option instance
				if (!optionsCache.TryGetValue(item.ItemType, out itemOptions))
				{
					itemOptions = context.Options.ItemOptions.GetMergedOptionsFor(item);
					optionsCache[item.ItemType] = itemOptions;
				}

				// Generate item context
				var itemContext = new PagerItemGenerationContext(context, item, itemOptions);

				// Generate item and add to list
				var renderingItem = GenerateRenderingItem(result, itemContext);
				renderingItemList.Add(renderingItem);
			}

			// Result
			result.Items = new ReadOnlyCollection<PagerRenderingItem>(renderingItemList);
			return result;
		}
コード例 #47
0
		/// <summary>
		///     Generate the content for a specified pager item.
		/// </summary>
		/// <param name="context">The generation context.</param>
		/// <returns>The generated HTML content for the pager item.</returns>
		public IHtmlContent GenerateContent(PagerItemGenerationContext context) => HtmlContentGenerator(context);
コード例 #48
0
		/// <summary>
		///     Generate the link url for the specified <see cref="PagerItem" />.
		/// </summary>
		/// <param name="context">The generation context.</param>
		public string GenerateLink(PagerItemGenerationContext context) => null;