4
4
5
5
namespace X . PagedList . Mvc . Core . Fluent ;
6
6
7
+ /// <summary>
8
+ /// Fluent builder that configures and renders a pager for an <see cref="IPagedList"/> in ASP.NET Core MVC.
9
+ /// </summary>
10
+ /// <remarks>
11
+ /// Uses <see cref="PagedListRenderOptions"/> to configure output and <see cref="IHtmlHelper"/> to render either
12
+ /// the default pager or a custom partial view.
13
+ /// </remarks>
7
14
internal sealed class HtmlPagerBuilder : IHtmlPagerBuilder
8
15
{
9
16
private readonly IHtmlHelper _htmlHelper ;
@@ -13,6 +20,11 @@ internal sealed class HtmlPagerBuilder : IHtmlPagerBuilder
13
20
private PagedListRenderOptions _options ;
14
21
private string ? _partialViewName ;
15
22
23
+ /// <summary>
24
+ /// Initializes a new instance of the <see cref="HtmlPagerBuilder"/> class.
25
+ /// </summary>
26
+ /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> used to render HTML.</param>
27
+ /// <param name="pagedList">The source <see cref="IPagedList"/> to paginate.</param>
16
28
public HtmlPagerBuilder ( IHtmlHelper htmlHelper , IPagedList pagedList )
17
29
{
18
30
_htmlHelper = htmlHelper ;
@@ -21,132 +33,151 @@ public HtmlPagerBuilder(IHtmlHelper htmlHelper, IPagedList pagedList)
21
33
_options = new PagedListRenderOptions ( ) ;
22
34
}
23
35
36
+ /// <inheritdoc />
24
37
public IHtmlPagerBuilder Url ( Func < int , string ? > builder )
25
38
{
26
39
_generatePageUrl = builder ;
27
40
28
41
return this ;
29
42
}
30
43
44
+ /// <inheritdoc />
31
45
public IHtmlPagerBuilder DisplayLinkToFirstPage ( PagedListDisplayMode displayMode = PagedListDisplayMode . Always )
32
46
{
33
47
_options . DisplayLinkToFirstPage = displayMode ;
34
48
35
49
return this ;
36
50
}
37
51
52
+ /// <inheritdoc />
38
53
public IHtmlPagerBuilder DisplayLinkToLastPage ( PagedListDisplayMode displayMode = PagedListDisplayMode . Always )
39
54
{
40
55
_options . DisplayLinkToLastPage = displayMode ;
41
56
42
57
return this ;
43
58
}
44
59
60
+ /// <inheritdoc />
45
61
public IHtmlPagerBuilder DisplayLinkToPreviousPage ( PagedListDisplayMode displayMode = PagedListDisplayMode . Always )
46
62
{
47
63
_options . DisplayLinkToPreviousPage = displayMode ;
48
64
49
65
return this ;
50
66
}
51
67
68
+ /// <inheritdoc />
52
69
public IHtmlPagerBuilder DisplayLinkToNextPage ( PagedListDisplayMode displayMode = PagedListDisplayMode . Always )
53
70
{
54
71
_options . DisplayLinkToNextPage = displayMode ;
55
72
56
73
return this ;
57
74
}
58
75
76
+ /// <inheritdoc />
59
77
public IHtmlPagerBuilder DisplayLinkToIndividualPages ( bool displayMode = true )
60
78
{
61
79
_options . DisplayLinkToIndividualPages = displayMode ;
62
80
63
81
return this ;
64
82
}
65
83
84
+ /// <inheritdoc />
66
85
public IHtmlPagerBuilder DisplayPageCountAndCurrentLocation ( bool displayMode = true )
67
86
{
68
87
_options . DisplayPageCountAndCurrentLocation = displayMode ;
69
88
70
89
return this ;
71
90
}
72
91
92
+ /// <inheritdoc />
73
93
public IHtmlPagerBuilder DisplayEllipsesWhenNotShowingAllPageNumbers ( bool displayMode = true )
74
94
{
75
95
_options . DisplayEllipsesWhenNotShowingAllPageNumbers = displayMode ;
76
96
77
97
return this ;
78
98
}
79
99
100
+ /// <inheritdoc />
80
101
public IHtmlPagerBuilder MaximumPageNumbersToDisplay ( int pageNumbers )
81
102
{
82
103
_options . MaximumPageNumbersToDisplay = pageNumbers ;
83
104
84
105
return this ;
85
106
}
86
107
108
+ /// <inheritdoc />
87
109
public IHtmlContent Classic ( )
88
110
{
89
111
_options = PagedListRenderOptions . Classic ;
90
112
91
113
return Build ( ) ;
92
114
}
93
115
116
+ /// <inheritdoc />
94
117
public IHtmlContent ClassicPlusFirstAndLast ( )
95
118
{
96
119
_options = PagedListRenderOptions . ClassicPlusFirstAndLast ;
97
120
98
121
return Build ( ) ;
99
122
}
100
123
124
+ /// <inheritdoc />
101
125
public IHtmlContent Minimal ( )
102
126
{
103
127
_options = PagedListRenderOptions . Minimal ;
104
128
105
129
return Build ( ) ;
106
130
}
107
131
132
+ /// <inheritdoc />
108
133
public IHtmlContent MinimalWithPageCountText ( )
109
134
{
110
135
_options = PagedListRenderOptions . MinimalWithPageCountText ;
111
136
112
137
return Build ( ) ;
113
138
}
114
139
140
+ /// <inheritdoc />
115
141
public IHtmlContent MinimalWithItemCountText ( )
116
142
{
117
143
_options = PagedListRenderOptions . MinimalWithItemCountText ;
118
144
119
145
return Build ( ) ;
120
146
}
121
147
148
+ /// <inheritdoc />
122
149
public IHtmlContent PageNumbersOnly ( )
123
150
{
124
151
_options = PagedListRenderOptions . PageNumbersOnly ;
125
152
126
153
return Build ( ) ;
127
154
}
128
155
156
+ /// <inheritdoc />
129
157
public IHtmlContent OnlyShowFivePagesAtATime ( )
130
158
{
131
159
_options = PagedListRenderOptions . OnlyShowFivePagesAtATime ;
132
160
133
161
return Build ( ) ;
134
162
}
135
163
164
+ /// <inheritdoc />
136
165
public IHtmlPagerBuilder WithPartialView ( string partialViewName )
137
166
{
138
167
_partialViewName = partialViewName ;
139
168
140
169
return this ;
141
170
}
142
171
172
+ /// <inheritdoc />
143
173
public IHtmlContent Build ( PagedListRenderOptions ? options )
144
174
{
145
175
_options = options ?? _options ;
146
176
147
177
return Build ( ) ;
148
178
}
149
179
180
+ /// <inheritdoc />
150
181
public IHtmlContent Build ( )
151
182
{
152
183
if ( string . IsNullOrWhiteSpace ( _partialViewName ) )
@@ -159,4 +190,4 @@ public IHtmlContent Build()
159
190
160
191
return _htmlHelper . Partial ( _partialViewName , _pagedList ) ;
161
192
}
162
- }
193
+ }
0 commit comments