4
4
using System ;
5
5
using Microsoft . AspNetCore . Components ;
6
6
using Microsoft . AspNetCore . Components . Server ;
7
+ using Microsoft . AspNetCore . Http . Connections ;
7
8
using Microsoft . AspNetCore . Routing ;
9
+ using Microsoft . AspNetCore . SignalR ;
8
10
9
11
namespace Microsoft . AspNetCore . Builder
10
12
{
@@ -14,7 +16,7 @@ namespace Microsoft.AspNetCore.Builder
14
16
public static class ComponentEndpointRouteBuilderExtensions
15
17
{
16
18
/// <summary>
17
- /// Maps the SignalR <see cref="ComponentHub" /> to the path <see cref="ComponentHub.DefaultPath"/> .
19
+ /// Maps the Blazor <see cref="Hub" /> to the default path .
18
20
/// </summary>
19
21
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
20
22
/// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
@@ -25,20 +27,41 @@ public static ComponentEndpointConventionBuilder MapBlazorHub(this IEndpointRout
25
27
throw new ArgumentNullException ( nameof ( endpoints ) ) ;
26
28
}
27
29
28
- return new ComponentEndpointConventionBuilder ( endpoints . MapHub < ComponentHub > ( ComponentHub . DefaultPath ) ) ;
30
+ return endpoints . MapBlazorHub ( configureOptions : _ => { } ) ;
29
31
}
30
32
31
33
/// <summary>
32
- /// Maps the SignalR <see cref="ComponentHub"/> to the path <see cref="ComponentHub.DefaultPath"/> and associates
34
+ /// Maps the Blazor <see cref="Hub" /> to the default path.
35
+ /// </summary>
36
+ /// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
37
+ /// <param name="configureOptions">A callback to configure dispatcher options.</param>
38
+ /// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
39
+ public static ComponentEndpointConventionBuilder MapBlazorHub ( this IEndpointRouteBuilder endpoints , Action < HttpConnectionDispatcherOptions > configureOptions )
40
+ {
41
+ if ( endpoints == null )
42
+ {
43
+ throw new ArgumentNullException ( nameof ( endpoints ) ) ;
44
+ }
45
+
46
+ if ( configureOptions == null )
47
+ {
48
+ throw new ArgumentNullException ( nameof ( configureOptions ) ) ;
49
+ }
50
+
51
+ return new ComponentEndpointConventionBuilder ( endpoints . MapHub < ComponentHub > ( ComponentHub . DefaultPath , configureOptions ) ) ;
52
+ }
53
+
54
+ /// <summary>
55
+ ///Maps the Blazor <see cref="Hub" /> to the default path and associates
33
56
/// the component <typeparamref name="TComponent"/> to this hub instance as the given DOM <paramref name="selector"/>.
34
57
/// </summary>
35
- /// <typeparam name="TComponent">The first <see cref="IComponent"/> associated with this <see cref="ComponentHub" />.</typeparam>
58
+ /// <typeparam name="TComponent">The first <see cref="IComponent"/> associated with this Blazor <see cref="Hub" />.</typeparam>
36
59
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
37
60
/// <param name="selector">The selector for the <typeparamref name="TComponent"/>.</param>
38
61
/// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
39
62
public static ComponentEndpointConventionBuilder MapBlazorHub < TComponent > (
40
63
this IEndpointRouteBuilder endpoints ,
41
- string selector ) where TComponent : IComponent
64
+ string selector ) where TComponent : IComponent
42
65
{
43
66
if ( endpoints == null )
44
67
{
@@ -54,11 +77,43 @@ public static ComponentEndpointConventionBuilder MapBlazorHub<TComponent>(
54
77
}
55
78
56
79
/// <summary>
57
- /// Maps the SignalR <see cref="ComponentHub"/> to the path <see cref="ComponentHub.DefaultPath"/> and associates
80
+ ///Maps the Blazor <see cref="Hub" /> to the default path and associates
81
+ /// the component <typeparamref name="TComponent"/> to this hub instance as the given DOM <paramref name="selector"/>.
82
+ /// </summary>
83
+ /// <typeparam name="TComponent">The first <see cref="IComponent"/> associated with this Blazor <see cref="Hub" />.</typeparam>
84
+ /// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
85
+ /// <param name="selector">The selector for the <typeparamref name="TComponent"/>.</param>
86
+ /// <param name="configureOptions">A callback to configure dispatcher options.</param>
87
+ /// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
88
+ public static ComponentEndpointConventionBuilder MapBlazorHub < TComponent > (
89
+ this IEndpointRouteBuilder endpoints ,
90
+ string selector ,
91
+ Action < HttpConnectionDispatcherOptions > configureOptions ) where TComponent : IComponent
92
+ {
93
+ if ( endpoints == null )
94
+ {
95
+ throw new ArgumentNullException ( nameof ( endpoints ) ) ;
96
+ }
97
+
98
+ if ( selector == null )
99
+ {
100
+ throw new ArgumentNullException ( nameof ( selector ) ) ;
101
+ }
102
+
103
+ if ( configureOptions == null )
104
+ {
105
+ throw new ArgumentNullException ( nameof ( configureOptions ) ) ;
106
+ }
107
+
108
+ return endpoints . MapBlazorHub ( typeof ( TComponent ) , selector , ComponentHub . DefaultPath , configureOptions ) ;
109
+ }
110
+
111
+ /// <summary>
112
+ ///Maps the Blazor <see cref="Hub" /> to the default path and associates
58
113
/// the component <paramref name="type"/> to this hub instance as the given DOM <paramref name="selector"/>.
59
114
/// </summary>
60
115
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
61
- /// <param name="type">The first <see cref="IComponent"/> associated with this <see cref="ComponentHub" />.</param>
116
+ /// <param name="type">The first <see cref="IComponent"/> associated with this Blazor <see cref="Hub" />.</param>
62
117
/// <param name="selector">The selector for the component.</param>
63
118
/// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
64
119
public static ComponentEndpointConventionBuilder MapBlazorHub (
@@ -85,13 +140,51 @@ public static ComponentEndpointConventionBuilder MapBlazorHub(
85
140
}
86
141
87
142
/// <summary>
88
- /// Maps the SignalR <see cref="ComponentHub"/> to the path <paramref name="path"/> and associates
143
+ ///Maps the Blazor <see cref="Hub" /> to the default path and associates
144
+ /// the component <paramref name="type"/> to this hub instance as the given DOM <paramref name="selector"/>.
145
+ /// </summary>
146
+ /// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
147
+ /// <param name="type">The first <see cref="IComponent"/> associated with this Blazor <see cref="Hub" />.</param>
148
+ /// <param name="selector">The selector for the component.</param>
149
+ /// <param name="configureOptions">A callback to configure dispatcher options.</param>
150
+ /// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
151
+ public static ComponentEndpointConventionBuilder MapBlazorHub (
152
+ this IEndpointRouteBuilder endpoints ,
153
+ Type type ,
154
+ string selector ,
155
+ Action < HttpConnectionDispatcherOptions > configureOptions )
156
+ {
157
+ if ( endpoints == null )
158
+ {
159
+ throw new ArgumentNullException ( nameof ( endpoints ) ) ;
160
+ }
161
+
162
+ if ( type == null )
163
+ {
164
+ throw new ArgumentNullException ( nameof ( type ) ) ;
165
+ }
166
+
167
+ if ( selector == null )
168
+ {
169
+ throw new ArgumentNullException ( nameof ( selector ) ) ;
170
+ }
171
+
172
+ if ( configureOptions == null )
173
+ {
174
+ throw new ArgumentNullException ( nameof ( configureOptions ) ) ;
175
+ }
176
+
177
+ return endpoints . MapBlazorHub ( type , selector , ComponentHub . DefaultPath , configureOptions ) ;
178
+ }
179
+
180
+ /// <summary>
181
+ /// Maps the Blazor <see cref="Hub" /> to the path <paramref name="path"/> and associates
89
182
/// the component <typeparamref name="TComponent"/> to this hub instance as the given DOM <paramref name="selector"/>.
90
183
/// </summary>
91
- /// <typeparam name="TComponent">The first <see cref="IComponent"/> associated with this <see cref="ComponentHub" />.</typeparam>
184
+ /// <typeparam name="TComponent">The first <see cref="IComponent"/> associated with this Blazor <see cref="Hub" />.</typeparam>
92
185
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
93
186
/// <param name="selector">The selector for the <typeparamref name="TComponent"/>.</param>
94
- /// <param name="path">The path to map to which the <see cref="ComponentHub"/> will be mapped .</param>
187
+ /// <param name="path">The path to map the Blazor <see cref="Hub" /> .</param>
95
188
/// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
96
189
public static ComponentEndpointConventionBuilder MapBlazorHub < TComponent > (
97
190
this IEndpointRouteBuilder endpoints ,
@@ -117,13 +210,52 @@ public static ComponentEndpointConventionBuilder MapBlazorHub<TComponent>(
117
210
}
118
211
119
212
/// <summary>
120
- /// Maps the SignalR <see cref="ComponentHub"/> to the path <paramref name="path"/> and associates
213
+ /// Maps the Blazor <see cref="Hub" /> to the path <paramref name="path"/> and associates
214
+ /// the component <typeparamref name="TComponent"/> to this hub instance as the given DOM <paramref name="selector"/>.
215
+ /// </summary>
216
+ /// <typeparam name="TComponent">The first <see cref="IComponent"/> associated with this Blazor <see cref="Hub" />.</typeparam>
217
+ /// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
218
+ /// <param name="selector">The selector for the <typeparamref name="TComponent"/>.</param>
219
+ /// <param name="path">The path to map the Blazor <see cref="Hub" />.</param>
220
+ /// <param name="configureOptions">A callback to configure dispatcher options.</param>
221
+ /// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
222
+ public static ComponentEndpointConventionBuilder MapBlazorHub < TComponent > (
223
+ this IEndpointRouteBuilder endpoints ,
224
+ string selector ,
225
+ string path ,
226
+ Action < HttpConnectionDispatcherOptions > configureOptions ) where TComponent : IComponent
227
+ {
228
+ if ( endpoints == null )
229
+ {
230
+ throw new ArgumentNullException ( nameof ( endpoints ) ) ;
231
+ }
232
+
233
+ if ( path == null )
234
+ {
235
+ throw new ArgumentNullException ( nameof ( path ) ) ;
236
+ }
237
+
238
+ if ( selector == null )
239
+ {
240
+ throw new ArgumentNullException ( nameof ( selector ) ) ;
241
+ }
242
+
243
+ if ( configureOptions == null )
244
+ {
245
+ throw new ArgumentNullException ( nameof ( configureOptions ) ) ;
246
+ }
247
+
248
+ return endpoints . MapBlazorHub ( typeof ( TComponent ) , selector , path , configureOptions ) ;
249
+ }
250
+
251
+ /// <summary>
252
+ /// Maps the Blazor <see cref="Hub" /> to the path <paramref name="path"/> and associates
121
253
/// the component <paramref name="componentType"/> to this hub instance as the given DOM <paramref name="selector"/>.
122
254
/// </summary>
123
255
/// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
124
- /// <param name="componentType">The first <see cref="IComponent"/> associated with this <see cref="ComponentHub" />.</param>
256
+ /// <param name="componentType">The first <see cref="IComponent"/> associated with this Blazor <see cref="Hub" />.</param>
125
257
/// <param name="selector">The selector for the <paramref name="componentType"/>.</param>
126
- /// <param name="path">The path to map to which the <see cref="ComponentHub"/> will be mapped .</param>
258
+ /// <param name="path">The path to map the Blazor <see cref="Hub" /> .</param>
127
259
/// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
128
260
public static ComponentEndpointConventionBuilder MapBlazorHub (
129
261
this IEndpointRouteBuilder endpoints ,
@@ -151,7 +283,52 @@ public static ComponentEndpointConventionBuilder MapBlazorHub(
151
283
throw new ArgumentNullException ( nameof ( selector ) ) ;
152
284
}
153
285
154
- return new ComponentEndpointConventionBuilder ( endpoints . MapHub < ComponentHub > ( path ) ) . AddComponent ( componentType , selector ) ;
286
+ return endpoints . MapBlazorHub ( componentType , selector , path , configureOptions : _ => { } ) ;
287
+ }
288
+
289
+ /// <summary>
290
+ /// Maps the Blazor <see cref="Hub" /> to the path <paramref name="path"/> and associates
291
+ /// the component <paramref name="componentType"/> to this hub instance as the given DOM <paramref name="selector"/>.
292
+ /// </summary>
293
+ /// <param name="endpoints">The <see cref="IEndpointRouteBuilder"/>.</param>
294
+ /// <param name="componentType">The first <see cref="IComponent"/> associated with this Blazor <see cref="Hub" />.</param>
295
+ /// <param name="selector">The selector for the <paramref name="componentType"/>.</param>
296
+ /// <param name="configureOptions">A callback to configure dispatcher options.</param>
297
+ /// <param name="path">The path to map the Blazor <see cref="Hub" />.</param>
298
+ /// <returns>The <see cref="ComponentEndpointConventionBuilder"/>.</returns>
299
+ public static ComponentEndpointConventionBuilder MapBlazorHub (
300
+ this IEndpointRouteBuilder endpoints ,
301
+ Type componentType ,
302
+ string selector ,
303
+ string path ,
304
+ Action < HttpConnectionDispatcherOptions > configureOptions )
305
+ {
306
+ if ( endpoints == null )
307
+ {
308
+ throw new ArgumentNullException ( nameof ( endpoints ) ) ;
309
+ }
310
+
311
+ if ( path == null )
312
+ {
313
+ throw new ArgumentNullException ( nameof ( path ) ) ;
314
+ }
315
+
316
+ if ( componentType == null )
317
+ {
318
+ throw new ArgumentNullException ( nameof ( componentType ) ) ;
319
+ }
320
+
321
+ if ( selector == null )
322
+ {
323
+ throw new ArgumentNullException ( nameof ( selector ) ) ;
324
+ }
325
+
326
+ if ( configureOptions == null )
327
+ {
328
+ throw new ArgumentNullException ( nameof ( configureOptions ) ) ;
329
+ }
330
+
331
+ return new ComponentEndpointConventionBuilder ( endpoints . MapHub < ComponentHub > ( path , configureOptions ) ) . AddComponent ( componentType , selector ) ;
155
332
}
156
333
}
157
334
}
0 commit comments