1- using System ;
2- using Microsoft . Extensions . Configuration ;
1+ using Microsoft . Extensions . Configuration ;
32using Microsoft . Extensions . DependencyInjection ;
43using Microsoft . Extensions . DependencyInjection . Extensions ;
54using Microsoft . Extensions . Options ;
1110using Orleans . Providers . MongoDB . Reminders ;
1211using Orleans . Providers . MongoDB . StorageProviders ;
1312using Orleans . Providers . MongoDB . StorageProviders . Serializers ;
14- using Orleans . Runtime ;
15- using Orleans . Storage ;
13+ using Orleans . Runtime . Hosting ;
14+ using System ;
1615
1716// ReSharper disable AccessToStaticMemberViaDerivedType
1817// ReSharper disable CheckNamespace
@@ -205,22 +204,11 @@ public static IServiceCollection AddMongoDBGrainStorage(this IServiceCollection
205204 Action < OptionsBuilder < MongoDBGrainStorageOptions > > configureOptions = null )
206205 {
207206 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-
215207 services . TryAddSingleton < IGrainStateSerializer , JsonGrainStateSerializer > ( ) ;
216-
217- services . ConfigureNamedOptionForLogging < MongoDBGrainStorageOptions > ( name ) ;
218-
219208 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 ) ;
224212 }
225213 }
226214}
0 commit comments