/// <summary>
        /// Configures Rebus to use SQL Server to store timeouts.
        /// </summary>
        public static void StoreInSqlServer(this StandardConfigurer <ITimeoutManager> configurer,
                                            string connectionStringOrConnectionStringName, string tableName, bool automaticallyCreateTables = true)
        {
            if (configurer == null)
            {
                throw new ArgumentNullException(nameof(configurer));
            }
            if (connectionStringOrConnectionStringName == null)
            {
                throw new ArgumentNullException(nameof(connectionStringOrConnectionStringName));
            }
            if (tableName == null)
            {
                throw new ArgumentNullException(nameof(tableName));
            }

            configurer.Register(c =>
            {
                var rebusLoggerFactory  = c.Get <IRebusLoggerFactory>();
                var connectionProvider  = new DbConnectionProvider(connectionStringOrConnectionStringName, rebusLoggerFactory);
                var subscriptionStorage = new SqlServerTimeoutManager(connectionProvider, tableName, rebusLoggerFactory);

                if (automaticallyCreateTables)
                {
                    subscriptionStorage.EnsureTableIsCreated();
                }

                return(subscriptionStorage);
            });
        }
        /// <summary>
        /// Configures Rebus to use SQL Server to store timeouts.
        /// </summary>
        public static void StoreInSqlServer(this StandardConfigurer <ITimeoutManager> configurer, string connectionStringOrConnectionStringName, string tableName, bool automaticallyCreateTables = true)
        {
            configurer.Register(c =>
            {
                var subscriptionStorage = new SqlServerTimeoutManager(new DbConnectionProvider(connectionStringOrConnectionStringName), tableName);

                if (automaticallyCreateTables)
                {
                    subscriptionStorage.EnsureTableIsCreated();
                }

                return(subscriptionStorage);
            });
        }
        /// <summary>
        /// Configures Rebus to use SQL Server to store timeouts.
        /// </summary>
        public static void StoreInSqlServer(this StandardConfigurer<ITimeoutManager> configurer, string connectionStringOrConnectionStringName, string tableName, bool automaticallyCreateTables = true)
        {
            configurer.Register(c =>
            {
                var subscriptionStorage = new SqlServerTimeoutManager(new DbConnectionProvider(connectionStringOrConnectionStringName), tableName);

                if (automaticallyCreateTables)
                {
                    subscriptionStorage.EnsureTableIsCreated();
                }

                return subscriptionStorage;
            });
        }
        /// <summary>
        /// Configures Rebus to use SQL Server to store timeouts.
        /// </summary>
        public static void StoreInSqlServer(this StandardConfigurer<ITimeoutManager> configurer,
            Func<Task<IDbConnection>> connectionFactory, string tableName, bool automaticallyCreateTables = true)
        {
            if (configurer == null) throw new ArgumentNullException(nameof(configurer));
            if (connectionFactory == null) throw new ArgumentNullException(nameof(connectionFactory));
            if (tableName == null) throw new ArgumentNullException(nameof(tableName));

            configurer.Register(c =>
            {
                var rebusLoggerFactory = c.Get<IRebusLoggerFactory>();
                var connectionProvider = new DbConnectionFactoryProvider(connectionFactory, rebusLoggerFactory);
                var subscriptionStorage = new SqlServerTimeoutManager(connectionProvider, tableName, rebusLoggerFactory);

                if (automaticallyCreateTables)
                {
                    subscriptionStorage.EnsureTableIsCreated();
                }

                return subscriptionStorage;
            });
        }