22using EntityDb . Abstractions . Transactions ;
33using EntityDb . Common . Transactions ;
44using EntityDb . Redis . Snapshots ;
5+ using Microsoft . Extensions . Configuration ;
56using Microsoft . Extensions . DependencyInjection ;
67using System ;
78using System . Diagnostics . CodeAnalysis ;
@@ -24,19 +25,21 @@ public static class IServiceCollectionExtensions
2425 /// <remarks>
2526 /// The production-ready implementation will store snapshots as they come in. If you need write an integration test,
2627 /// consider using
27- /// <see cref="AddTestModeRedisSnapshots{TEntity}(IServiceCollection, string, Func{IServiceProvider , string})" />
28+ /// <see cref="AddTestModeRedisSnapshots{TEntity}(IServiceCollection, string, Func{IConfiguration , string})" />
2829 /// instead.
2930 /// </remarks>
3031 [ ExcludeFromCodeCoverage ( Justification = "Tests use TestMode." ) ]
3132 public static void AddRedisSnapshots < TEntity > ( this IServiceCollection serviceCollection , string keyNamespace ,
32- Func < IServiceProvider , string > getConnectionString )
33+ Func < IConfiguration , string > getConnectionString )
3334 {
3435 serviceCollection . AddSingleton < ITransactionSubscriber < TEntity > > ( serviceProvider =>
3536 SnapshottingTransactionSubscriber < TEntity > . Create ( serviceProvider , false ) ) ;
3637
3738 serviceCollection . AddSingleton < ISnapshotRepositoryFactory < TEntity > > ( serviceProvider =>
3839 {
39- var connectionString = getConnectionString . Invoke ( serviceProvider ) ;
40+ var configuration = serviceProvider . GetRequiredService < IConfiguration > ( ) ;
41+
42+ var connectionString = getConnectionString . Invoke ( configuration ) ;
4043
4144 return RedisSnapshotRepositoryFactory < TEntity > . Create ( serviceProvider , connectionString , keyNamespace ) ;
4245 } ) ;
@@ -57,14 +60,16 @@ public static void AddRedisSnapshots<TEntity>(this IServiceCollection serviceCol
5760 /// when the repository is disposed.
5861 /// </remarks>
5962 public static void AddTestModeRedisSnapshots < TEntity > ( this IServiceCollection serviceCollection ,
60- string keyNamespace , Func < IServiceProvider , string > getConnectionString )
63+ string keyNamespace , Func < IConfiguration , string > getConnectionString )
6164 {
6265 serviceCollection . AddSingleton < ITransactionSubscriber < TEntity > > ( serviceProvider =>
6366 SnapshottingTransactionSubscriber < TEntity > . Create ( serviceProvider , true ) ) ;
6467
6568 serviceCollection . AddSingleton < ISnapshotRepositoryFactory < TEntity > > ( serviceProvider =>
6669 {
67- var connectionString = getConnectionString . Invoke ( serviceProvider ) ;
70+ var configuration = serviceProvider . GetRequiredService < IConfiguration > ( ) ;
71+
72+ var connectionString = getConnectionString . Invoke ( configuration ) ;
6873
6974 return TestModeRedisSnapshotRepositoryFactory < TEntity > . Create ( serviceProvider , connectionString ,
7075 keyNamespace ) ;
0 commit comments