1
- using System ;
2
- using Microsoft . Extensions . Configuration ;
1
+ using Microsoft . Extensions . Configuration ;
3
2
using Microsoft . Extensions . DependencyInjection ;
4
3
using Microsoft . Extensions . DependencyInjection . Extensions ;
5
4
using Microsoft . Extensions . Options ;
11
10
using Orleans . Providers . MongoDB . Reminders ;
12
11
using Orleans . Providers . MongoDB . StorageProviders ;
13
12
using Orleans . Providers . MongoDB . StorageProviders . Serializers ;
14
- using Orleans . Runtime ;
15
- using Orleans . Storage ;
13
+ using Orleans . Runtime . Hosting ;
14
+ using System ;
16
15
17
16
// ReSharper disable AccessToStaticMemberViaDerivedType
18
17
// ReSharper disable CheckNamespace
@@ -205,22 +204,11 @@ public static IServiceCollection AddMongoDBGrainStorage(this IServiceCollection
205
204
Action < OptionsBuilder < MongoDBGrainStorageOptions > > configureOptions = null )
206
205
{
207
206
configureOptions ? . Invoke ( services . AddOptions < MongoDBGrainStorageOptions > ( name ) ) ;
208
- services . AddTransient < IPostConfigureOptions < MongoDBGrainStorageOptions > , MongoDBGrainStorageConfigurator > ( ) ;
209
-
210
- if ( string . Equals ( name , ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME , StringComparison . Ordinal ) )
211
- {
212
- services . TryAddSingleton ( sp => sp . GetServiceByName < IGrainStorage > ( ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME ) ) ;
213
- }
214
-
215
207
services . TryAddSingleton < IGrainStateSerializer , JsonGrainStateSerializer > ( ) ;
216
-
217
- services . ConfigureNamedOptionForLogging < MongoDBGrainStorageOptions > ( name ) ;
218
-
219
208
services . AddTransient < IConfigurationValidator > ( sp => new MongoDBGrainStorageOptionsValidator ( sp . GetRequiredService < IOptionsMonitor < MongoDBGrainStorageOptions > > ( ) . Get ( name ) , name ) ) ;
220
- services . AddSingletonNamedService ( name , MongoGrainStorageFactory . Create ) ;
221
- services . AddSingletonNamedService ( name , ( s , n ) => ( ILifecycleParticipant < ISiloLifecycle > ) s . GetRequiredServiceByName < IGrainStorage > ( n ) ) ;
222
-
223
- return services ;
209
+ services . ConfigureNamedOptionForLogging < MongoDBGrainStorageOptions > ( name ) ;
210
+ services . AddTransient < IPostConfigureOptions < MongoDBGrainStorageOptions > , MongoDBGrainStorageConfigurator > ( ) ;
211
+ return services . AddGrainStorage ( name , MongoGrainStorageFactory . Create ) ;
224
212
}
225
213
}
226
214
}
0 commit comments