Sakura.AspNetCore.Extensions/Sakura.AspNetCore.Mvc.PagedList/Internal/DefaultPagerListGenerator.cs
/// <summary>
///     Generate all pager items for a layout sequence.
/// </summary>
/// <param name="currentPage">The current page number.</param>
/// <param name="totalPage">The count of total pages.</param>
/// <param name="layout">A sequence that indicates the layout of the pager.</param>
/// <param name="options">The options of the pager.</param>
/// <returns>The collection for all pager items.</returns>
Generate all pager items for a layout sequence.
Generate all pager items for a layout sequence .
private IEnumerable<PagerItem> GenerateItemsCore(int currentPage, int totalPage,
			IEnumerable<PagerLayoutElement> layout, PagerOptions options)
		{
			var layoutResult = new Dictionary<PagerLayoutElement, PagerItem[]>();
			var result = new List<PagerItem>();
			foreach (var element in layout)
			{
				if (!layoutResult.TryGetValue(element, out var elementResult))
				{
					elementResult = GenerateItemsForLayoutElement(element, currentPage, totalPage, options).ToArray();
					layoutResult[element] = elementResult;
				}
				result.AddRange(elementResult);
			}
			return result;
		}
private IEnumerable < PagerItem > GenerateItemsCore ( int currentPage , int totalPage , IEnumerable < PagerLayoutElement > layout , PagerOptions options ) { var layoutResult = new Dictionary < PagerLayoutElement , PagerItem [ ] > ( ) ; var result = new List < PagerItem > ( ) ; foreach ( var element in layout ) { if ( ! layoutResult . TryGetValue ( element , out var elementResult ) ) { elementResult = GenerateItemsForLayoutElement ( element , currentPage , totalPage , options ) . ToArray ( ) ; layoutResult [ element ] = elementResult ; } result . AddRange ( elementResult ) ; } return result ; }
Generate all pager items for a layout sequence.
Generate all pager items for a layout sequence .
// Dictionary for each layout, used to cache generation results // If the dictionary not contains the layout result, generate once and store it to the dictionary
The collection for all pager items.
The collection for all pager items .
currentPage
int
The current page number.
The current page number .
totalPage
int
The count of total pages.
The count of total pages .
layout
IEnumerable<PagerLayoutElement>
A sequence that indicates the layout of the pager.
A sequence that indicates the layout of the pager .
options
PagerOptions
The options of the pager.
The options of the pager .