src/Orleans.Persistence.Memory/Hosting/MemoryGrainStorageSiloBuilderExtensions.cs
/// <summary>
/// Configure silo to use memory grain storage.
/// </summary>
/// <param name="builder">The builder.</param>
/// <param name="name">The name of the storage provider. This must match with the <c>StorageName</c> property specified when injecting state into a grain.</param>
/// <param name="configureOptions">The configuration delegate.</param>
/// <returns>The silo builder.</returns>
Configure silo to use memory grain storage.
Configure silo to use memory grain storage .
public static ISiloBuilder AddMemoryGrainStorage(this ISiloBuilder builder, string name, Action<OptionsBuilder<MemoryGrainStorageOptions>> configureOptions = null)
        {
            return builder
                .ConfigureServices(services =>
                {
                    configureOptions?.Invoke(services.AddOptions<MemoryGrainStorageOptions>(name));
                    services.ConfigureNamedOptionForLogging<MemoryGrainStorageOptions>(name);
                    if (string.Equals(name, ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME, StringComparison.Ordinal))
                    {
                        services.TryAddSingleton(sp => sp.GetServiceByName<IGrainStorage>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME));
                    }
                    services.AddSingletonNamedService<IGrainStorage>(name, MemoryGrainStorageFactory.Create);
                });
        }
public static ISiloBuilder AddMemoryGrainStorage ( this ISiloBuilder builder , string name , Action < OptionsBuilder < MemoryGrainStorageOptions > > configureOptions = null ) { return builder . ConfigureServices ( services => { configureOptions ? . Invoke ( services . AddOptions < MemoryGrainStorageOptions > ( name ) ) ; services . ConfigureNamedOptionForLogging < MemoryGrainStorageOptions > ( name ) ; if ( string . Equals ( name , ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME , StringComparison . Ordinal ) ) { services . TryAddSingleton ( sp => sp . GetServiceByName < IGrainStorage > ( ProviderConstants . DEFAULT_STORAGE_PROVIDER_NAME ) ) ; } services . AddSingletonNamedService < IGrainStorage > ( name , MemoryGrainStorageFactory . Create ) ; } ) ; }
Configure silo to use memory grain storage.
Configure silo to use memory grain storage .
The silo builder.
The silo builder .
ISiloBuilder
this
name
string
The name of the storage provider. This must match with the StorageName
The name of the storage provider . This must match with the StorageName
configureOptions
Action<OptionsBuilder<MemoryGrainStorageOptions>>
The configuration delegate.
The configuration delegate .
builder
None