/// <summary> /// Adds a stream store backed configuration provider. /// </summary> /// <param name="builder">The configuration builer that SSS will be aded to </param> /// <param name="connectionStringKey">The key that holds the connection string</param> /// <param name="streamStoreFactory">Builds the stream store implementation</param> /// <param name="subscribeToChanges">Should we subscribe to changes?</param> /// <param name="errorHandler">What to do if database is not available. </param> /// <param name="messageHooks">Message hooks that help you to implement encryption</param> /// <returns></returns> public static IConfigurationBuilder AddStreamStore(this IConfigurationBuilder builder, string connectionStringKey, BuildStreamStoreFromConnectionString streamStoreFactory, bool subscribeToChanges = false, ErrorHandler errorHandler = null, IConfigurationSettingsHooks messageHooks = null) { builder.Add(new StreamStoreConfigurationSource(connectionStringKey, streamStoreFactory) { SubscribeToChanges = subscribeToChanges, ErrorHandler = errorHandler, MessageHooks = messageHooks }); return(builder); }
public StreamStoreConfigurationSource(string connectionStringKey, BuildStreamStoreFromConnectionString streamStoreFactory) { _buildStreamStoreFromConfig = (c => { var connectionString = c[connectionStringKey]; if (string.IsNullOrEmpty(connectionString)) { throw new InvalidOperationException( $"Cannot create SqlStreamStore repository, becuase connection string (key: '{connectionStringKey}') has not been configured."); } return(streamStoreFactory(connectionString)); }); }