3
3
using System . Linq ;
4
4
using System . Reflection ;
5
5
using MediatR ;
6
+ using MediatR . Entities ;
6
7
using MediatR . NotificationPublishers ;
7
8
using MediatR . Pipeline ;
8
9
using MediatR . Registration ;
@@ -15,7 +16,7 @@ public class MediatRServiceConfiguration
15
16
/// Optional filter for types to register. Default value is a function returning true.
16
17
/// </summary>
17
18
public Func < Type , bool > TypeEvaluator { get ; set ; } = t => true ;
18
-
19
+
19
20
/// <summary>
20
21
/// Mediator implementation type to register. Default is <see cref="Mediator"/>
21
22
/// </summary>
@@ -69,31 +70,6 @@ public class MediatRServiceConfiguration
69
70
/// </summary>
70
71
public bool AutoRegisterRequestProcessors { get ; set ; }
71
72
72
- /// <summary>
73
- /// Configure the maximum number of type parameters that a generic request handler can have. To Disable this constraint, set the value to 0.
74
- /// </summary>
75
- public int MaxGenericTypeParameters { get ; set ; } = 10 ;
76
-
77
- /// <summary>
78
- /// Configure the maximum number of types that can close a generic request type parameter constraint. To Disable this constraint, set the value to 0.
79
- /// </summary>
80
- public int MaxTypesClosing { get ; set ; } = 100 ;
81
-
82
- /// <summary>
83
- /// Configure the Maximum Amount of Generic RequestHandler Types MediatR will try to register. To Disable this constraint, set the value to 0.
84
- /// </summary>
85
- public int MaxGenericTypeRegistrations { get ; set ; } = 125000 ;
86
-
87
- /// <summary>
88
- /// Configure the Timeout in Milliseconds that the GenericHandler Registration Process will exit with error. To Disable this constraint, set the value to 0.
89
- /// </summary>
90
- public int RegistrationTimeout { get ; set ; } = 15000 ;
91
-
92
- /// <summary>
93
- /// Flag that controlls whether MediatR will attempt to register handlers that containg generic type parameters.
94
- /// </summary>
95
- public bool RegisterGenericHandlers { get ; set ; } = false ;
96
-
97
73
/// <summary>
98
74
/// Register various handlers from assembly containing given type
99
75
/// </summary>
@@ -222,6 +198,37 @@ public MediatRServiceConfiguration AddOpenBehavior(Type openBehaviorType, Servic
222
198
return this ;
223
199
}
224
200
201
+ /// <summary>
202
+ /// Registers multiple open behavior types against the <see cref="IPipelineBehavior{TRequest,TResponse}"/> open generic interface type
203
+ /// </summary>
204
+ /// <param name="openBehaviorTypes">An open generic behavior type list includes multiple open generic behavior types.</param>
205
+ /// <param name="serviceLifetime">Optional service lifetime, defaults to <see cref="ServiceLifetime.Transient"/>.</param>
206
+ /// <returns>This</returns>
207
+ public MediatRServiceConfiguration AddOpenBehaviors ( IEnumerable < Type > openBehaviorTypes , ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
208
+ {
209
+ foreach ( var openBehaviorType in openBehaviorTypes )
210
+ {
211
+ AddOpenBehavior ( openBehaviorType , serviceLifetime ) ;
212
+ }
213
+
214
+ return this ;
215
+ }
216
+
217
+ /// <summary>
218
+ /// Registers open behaviors against the <see cref="IPipelineBehavior{TRequest,TResponse}"/> open generic interface type
219
+ /// </summary>
220
+ /// <param name="openBehaviors">An open generic behavior list includes multiple <see cref="OpenBehavior"/> open generic behaviors.</param>
221
+ /// <returns>This</returns>
222
+ public MediatRServiceConfiguration AddOpenBehaviors ( IEnumerable < OpenBehavior > openBehaviors )
223
+ {
224
+ foreach ( var openBehavior in openBehaviors )
225
+ {
226
+ AddOpenBehavior ( openBehavior . OpenBehaviorType ! , openBehavior . ServiceLifetime ) ;
227
+ }
228
+
229
+ return this ;
230
+ }
231
+
225
232
/// <summary>
226
233
/// Register a closed stream behavior type
227
234
/// </summary>
@@ -231,7 +238,7 @@ public MediatRServiceConfiguration AddOpenBehavior(Type openBehaviorType, Servic
231
238
/// <returns>This</returns>
232
239
public MediatRServiceConfiguration AddStreamBehavior < TServiceType , TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
233
240
=> AddStreamBehavior ( typeof ( TServiceType ) , typeof ( TImplementationType ) , serviceLifetime ) ;
234
-
241
+
235
242
/// <summary>
236
243
/// Register a closed stream behavior type
237
244
/// </summary>
@@ -245,7 +252,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type serviceType, Type impl
245
252
246
253
return this ;
247
254
}
248
-
255
+
249
256
/// <summary>
250
257
/// Register a closed stream behavior type against all <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> implementations
251
258
/// </summary>
@@ -254,7 +261,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type serviceType, Type impl
254
261
/// <returns>This</returns>
255
262
public MediatRServiceConfiguration AddStreamBehavior < TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
256
263
=> AddStreamBehavior ( typeof ( TImplementationType ) , serviceLifetime ) ;
257
-
264
+
258
265
/// <summary>
259
266
/// Register a closed stream behavior type against all <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> implementations
260
267
/// </summary>
@@ -277,7 +284,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type implementationType, Se
277
284
278
285
return this ;
279
286
}
280
-
287
+
281
288
/// <summary>
282
289
/// Registers an open stream behavior type against the <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> open generic interface type
283
290
/// </summary>
@@ -316,7 +323,7 @@ public MediatRServiceConfiguration AddOpenStreamBehavior(Type openBehaviorType,
316
323
/// <returns>This</returns>
317
324
public MediatRServiceConfiguration AddRequestPreProcessor < TServiceType , TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
318
325
=> AddRequestPreProcessor ( typeof ( TServiceType ) , typeof ( TImplementationType ) , serviceLifetime ) ;
319
-
326
+
320
327
/// <summary>
321
328
/// Register a closed request pre processor type
322
329
/// </summary>
@@ -360,10 +367,10 @@ public MediatRServiceConfiguration AddRequestPreProcessor(Type implementationTyp
360
367
{
361
368
RequestPreProcessorsToRegister . Add ( new ServiceDescriptor ( implementedPreProcessorType , implementationType , serviceLifetime ) ) ;
362
369
}
363
-
370
+
364
371
return this ;
365
372
}
366
-
373
+
367
374
/// <summary>
368
375
/// Registers an open request pre processor type against the <see cref="IRequestPreProcessor{TRequest}"/> open generic interface type
369
376
/// </summary>
@@ -392,7 +399,7 @@ public MediatRServiceConfiguration AddOpenRequestPreProcessor(Type openBehaviorT
392
399
393
400
return this ;
394
401
}
395
-
402
+
396
403
/// <summary>
397
404
/// Register a closed request post processor type
398
405
/// </summary>
@@ -402,7 +409,7 @@ public MediatRServiceConfiguration AddOpenRequestPreProcessor(Type openBehaviorT
402
409
/// <returns>This</returns>
403
410
public MediatRServiceConfiguration AddRequestPostProcessor < TServiceType , TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
404
411
=> AddRequestPostProcessor ( typeof ( TServiceType ) , typeof ( TImplementationType ) , serviceLifetime ) ;
405
-
412
+
406
413
/// <summary>
407
414
/// Register a closed request post processor type
408
415
/// </summary>
@@ -416,7 +423,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type serviceType, Typ
416
423
417
424
return this ;
418
425
}
419
-
426
+
420
427
/// <summary>
421
428
/// Register a closed request post processor type against all <see cref="IRequestPostProcessor{TRequest,TResponse}"/> implementations
422
429
/// </summary>
@@ -425,7 +432,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type serviceType, Typ
425
432
/// <returns>This</returns>
426
433
public MediatRServiceConfiguration AddRequestPostProcessor < TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
427
434
=> AddRequestPostProcessor ( typeof ( TImplementationType ) , serviceLifetime ) ;
428
-
435
+
429
436
/// <summary>
430
437
/// Register a closed request post processor type against all <see cref="IRequestPostProcessor{TRequest,TResponse}"/> implementations
431
438
/// </summary>
@@ -447,7 +454,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type implementationTy
447
454
}
448
455
return this ;
449
456
}
450
-
457
+
451
458
/// <summary>
452
459
/// Registers an open request post processor type against the <see cref="IRequestPostProcessor{TRequest,TResponse}"/> open generic interface type
453
460
/// </summary>
0 commit comments