33using System . Linq ;
44using System . Reflection ;
55using MediatR ;
6+ using MediatR . Entities ;
67using MediatR . NotificationPublishers ;
78using MediatR . Pipeline ;
89using MediatR . Registration ;
@@ -15,7 +16,7 @@ public class MediatRServiceConfiguration
1516 /// Optional filter for types to register. Default value is a function returning true.
1617 /// </summary>
1718 public Func < Type , bool > TypeEvaluator { get ; set ; } = t => true ;
18-
19+
1920 /// <summary>
2021 /// Mediator implementation type to register. Default is <see cref="Mediator"/>
2122 /// </summary>
@@ -69,31 +70,6 @@ public class MediatRServiceConfiguration
6970 /// </summary>
7071 public bool AutoRegisterRequestProcessors { get ; set ; }
7172
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-
9773 /// <summary>
9874 /// Register various handlers from assembly containing given type
9975 /// </summary>
@@ -222,6 +198,37 @@ public MediatRServiceConfiguration AddOpenBehavior(Type openBehaviorType, Servic
222198 return this ;
223199 }
224200
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+
225232 /// <summary>
226233 /// Register a closed stream behavior type
227234 /// </summary>
@@ -231,7 +238,7 @@ public MediatRServiceConfiguration AddOpenBehavior(Type openBehaviorType, Servic
231238 /// <returns>This</returns>
232239 public MediatRServiceConfiguration AddStreamBehavior < TServiceType , TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
233240 => AddStreamBehavior ( typeof ( TServiceType ) , typeof ( TImplementationType ) , serviceLifetime ) ;
234-
241+
235242 /// <summary>
236243 /// Register a closed stream behavior type
237244 /// </summary>
@@ -245,7 +252,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type serviceType, Type impl
245252
246253 return this ;
247254 }
248-
255+
249256 /// <summary>
250257 /// Register a closed stream behavior type against all <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> implementations
251258 /// </summary>
@@ -254,7 +261,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type serviceType, Type impl
254261 /// <returns>This</returns>
255262 public MediatRServiceConfiguration AddStreamBehavior < TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
256263 => AddStreamBehavior ( typeof ( TImplementationType ) , serviceLifetime ) ;
257-
264+
258265 /// <summary>
259266 /// Register a closed stream behavior type against all <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> implementations
260267 /// </summary>
@@ -277,7 +284,7 @@ public MediatRServiceConfiguration AddStreamBehavior(Type implementationType, Se
277284
278285 return this ;
279286 }
280-
287+
281288 /// <summary>
282289 /// Registers an open stream behavior type against the <see cref="IStreamPipelineBehavior{TRequest,TResponse}"/> open generic interface type
283290 /// </summary>
@@ -316,7 +323,7 @@ public MediatRServiceConfiguration AddOpenStreamBehavior(Type openBehaviorType,
316323 /// <returns>This</returns>
317324 public MediatRServiceConfiguration AddRequestPreProcessor < TServiceType , TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
318325 => AddRequestPreProcessor ( typeof ( TServiceType ) , typeof ( TImplementationType ) , serviceLifetime ) ;
319-
326+
320327 /// <summary>
321328 /// Register a closed request pre processor type
322329 /// </summary>
@@ -360,10 +367,10 @@ public MediatRServiceConfiguration AddRequestPreProcessor(Type implementationTyp
360367 {
361368 RequestPreProcessorsToRegister . Add ( new ServiceDescriptor ( implementedPreProcessorType , implementationType , serviceLifetime ) ) ;
362369 }
363-
370+
364371 return this ;
365372 }
366-
373+
367374 /// <summary>
368375 /// Registers an open request pre processor type against the <see cref="IRequestPreProcessor{TRequest}"/> open generic interface type
369376 /// </summary>
@@ -392,7 +399,7 @@ public MediatRServiceConfiguration AddOpenRequestPreProcessor(Type openBehaviorT
392399
393400 return this ;
394401 }
395-
402+
396403 /// <summary>
397404 /// Register a closed request post processor type
398405 /// </summary>
@@ -402,7 +409,7 @@ public MediatRServiceConfiguration AddOpenRequestPreProcessor(Type openBehaviorT
402409 /// <returns>This</returns>
403410 public MediatRServiceConfiguration AddRequestPostProcessor < TServiceType , TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
404411 => AddRequestPostProcessor ( typeof ( TServiceType ) , typeof ( TImplementationType ) , serviceLifetime ) ;
405-
412+
406413 /// <summary>
407414 /// Register a closed request post processor type
408415 /// </summary>
@@ -416,7 +423,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type serviceType, Typ
416423
417424 return this ;
418425 }
419-
426+
420427 /// <summary>
421428 /// Register a closed request post processor type against all <see cref="IRequestPostProcessor{TRequest,TResponse}"/> implementations
422429 /// </summary>
@@ -425,7 +432,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type serviceType, Typ
425432 /// <returns>This</returns>
426433 public MediatRServiceConfiguration AddRequestPostProcessor < TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
427434 => AddRequestPostProcessor ( typeof ( TImplementationType ) , serviceLifetime ) ;
428-
435+
429436 /// <summary>
430437 /// Register a closed request post processor type against all <see cref="IRequestPostProcessor{TRequest,TResponse}"/> implementations
431438 /// </summary>
@@ -447,7 +454,7 @@ public MediatRServiceConfiguration AddRequestPostProcessor(Type implementationTy
447454 }
448455 return this ;
449456 }
450-
457+
451458 /// <summary>
452459 /// Registers an open request post processor type against the <see cref="IRequestPostProcessor{TRequest,TResponse}"/> open generic interface type
453460 /// </summary>
0 commit comments