@@ -89,15 +89,18 @@ public static void AddEntity<TEntity>(this IServiceCollection serviceCollection)
8989 /// </summary>
9090 /// <param name="serviceCollection">The service collection.</param>
9191 /// <param name="snapshotSessionOptionsName">The agent's intent for the snapshot repository.</param>
92- /// <param name="synchronousMode ">If <c>true</c> then snapshots will be synchronously recorded.</param>
92+ /// <param name="testMode ">If <c>true</c> then snapshots will be synchronously recorded.</param>
9393 /// <typeparam name="TEntity">The type of the entity.</typeparam>
9494 public static void AddEntitySnapshotTransactionSubscriber < TEntity > ( this IServiceCollection serviceCollection ,
95- string snapshotSessionOptionsName , bool synchronousMode = false )
95+ string snapshotSessionOptionsName , bool testMode = false )
9696 where TEntity : IEntity < TEntity > , ISnapshot < TEntity >
9797 {
98- serviceCollection . AddSingleton < ITransactionSubscriber > ( serviceProvider =>
99- EntitySnapshotTransactionSubscriber < TEntity > . Create ( serviceProvider , snapshotSessionOptionsName ,
100- synchronousMode ) ) ;
98+ serviceCollection . Add < ITransactionSubscriber >
99+ (
100+ testMode ? ServiceLifetime . Singleton : ServiceLifetime . Scoped ,
101+ serviceProvider => EntitySnapshotTransactionSubscriber < TEntity > . Create ( serviceProvider , snapshotSessionOptionsName ,
102+ testMode )
103+ ) ;
101104 }
102105
103106 /// <summary>
@@ -121,15 +124,18 @@ public static void AddProjection<TProjection, TProjectionStrategy>(
121124 /// </summary>
122125 /// <param name="serviceCollection">The service collection.</param>
123126 /// <param name="snapshotSessionOptionsName">The agent's intent for the snapshot repository.</param>
124- /// <param name="synchronousMode ">If <c>true</c> then snapshots will be synchronously recorded.</param>
127+ /// <param name="testMode ">If <c>true</c> then snapshots will be synchronously recorded.</param>
125128 /// <typeparam name="TProjection">The type of the projection.</typeparam>
126129 public static void AddProjectionSnapshotTransactionSubscriber < TProjection > (
127130 this IServiceCollection serviceCollection ,
128- string snapshotSessionOptionsName , bool synchronousMode = false )
131+ string snapshotSessionOptionsName , bool testMode = false )
129132 where TProjection : IProjection < TProjection > , ISnapshot < TProjection >
130133 {
131- serviceCollection . AddSingleton < ITransactionSubscriber > ( serviceProvider =>
132- ProjectionSnapshotTransactionSubscriber < TProjection > . Create ( serviceProvider , snapshotSessionOptionsName ,
133- synchronousMode ) ) ;
134+ serviceCollection . Add < ITransactionSubscriber >
135+ (
136+ testMode ? ServiceLifetime . Singleton : ServiceLifetime . Scoped ,
137+ serviceProvider => ProjectionSnapshotTransactionSubscriber < TProjection > . Create ( serviceProvider , snapshotSessionOptionsName ,
138+ testMode )
139+ ) ;
134140 }
135141}
0 commit comments