@@ -47,6 +47,11 @@ public class MediatRServiceConfiguration
4747 /// </summary>
4848 public List < ServiceDescriptor > BehaviorsToRegister { get ; } = new ( ) ;
4949
50+ /// <summary>
51+ /// List of stream behaviors to register in specific order
52+ /// </summary>
53+ public List < ServiceDescriptor > StreamBehaviorsToRegister { get ; } = new ( ) ;
54+
5055 /// <summary>
5156 /// Register various handlers from assembly containing given type
5257 /// </summary>
@@ -140,4 +145,28 @@ public MediatRServiceConfiguration AddOpenBehavior(Type openBehaviorType, Servic
140145
141146 return this ;
142147 }
148+
149+ /// <summary>
150+ /// Register a closed stream behavior type
151+ /// </summary>
152+ /// <typeparam name="TServiceType">Closed stream behavior interface type</typeparam>
153+ /// <typeparam name="TImplementationType">Closed stream behavior implementation type</typeparam>
154+ /// <param name="serviceLifetime">Optional service lifetime, defaults to <see cref="ServiceLifetime.Transient"/>.</param>
155+ /// <returns>This</returns>
156+ public MediatRServiceConfiguration AddStreamBehavior < TServiceType , TImplementationType > ( ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
157+ => AddStreamBehavior ( typeof ( TServiceType ) , typeof ( TImplementationType ) , serviceLifetime ) ;
158+
159+ /// <summary>
160+ /// Register a closed stream behavior type
161+ /// </summary>
162+ /// <param name="serviceType">Closed stream behavior interface type</param>
163+ /// <param name="implementationType">Closed stream behavior implementation type</param>
164+ /// <param name="serviceLifetime">Optional service lifetime, defaults to <see cref="ServiceLifetime.Transient"/>.</param>
165+ /// <returns>This</returns>
166+ public MediatRServiceConfiguration AddStreamBehavior ( Type serviceType , Type implementationType , ServiceLifetime serviceLifetime = ServiceLifetime . Transient )
167+ {
168+ StreamBehaviorsToRegister . Add ( new ServiceDescriptor ( serviceType , implementationType , serviceLifetime ) ) ;
169+
170+ return this ;
171+ }
143172}
0 commit comments