/// <summary>Add <see cref="FeatureFlagsSettings"/> to the DI container.  The two
        /// connection strings are hardcoded as "featureFlags" and "featureFlagsInitialization".
        /// </summary>
        /// <param name="services"><see cref="IServiceCollection"/></param>
        /// <param name="configuration"><see cref="IConfiguration"/></param>
        /// <param name="featureFlagAssemblies">A list of assemblies to scan for classes inheriting from
        /// <see cref="Feature"/>.</param>
        /// <param name="connectionString">Connection string for SELECT/INSERT/DELETE operations.</param>
        /// <param name="initializationConnectionString">Connection string for the CREATE TABLE operation.</param>
        /// <param name="sqlSessionManagerSettings">Optional <see cref="SqlSessionManagerSettings"/></param>
        /// <returns><see cref="IServiceCollection"/></returns>
        /// <exception cref="Exception">When the connection strings are missing/empty.</exception>
        public static IServiceCollection AddFeatureFlagSettings(
            this IServiceCollection services,
            IConfiguration configuration,
            IEnumerable <Assembly> featureFlagAssemblies,
            string connectionString,
            string initializationConnectionString,
            SqlSessionManagerSettings sqlSessionManagerSettings = null
            )
        {
            services.TryAddSingleton(serviceProvider =>
            {
                if (string.IsNullOrEmpty(connectionString))
                {
                    throw new ArgumentNullException(nameof(connectionString));
                }

                if (string.IsNullOrEmpty(initializationConnectionString))
                {
                    throw new ArgumentNullException(nameof(initializationConnectionString));
                }

                sqlSessionManagerSettings = sqlSessionManagerSettings
                                            ?? new SQLServerSessionManagerSettings
                {
                    FeatureSchemaName     = "dbo",
                    FeatureTableName      = "RimDevAspNetCoreFeatureFlags",
                    FeatureNameColumn     = "FeatureName",
                    FeatureValueColumn    = "Enabled",
                    ConnectionString      = connectionString,
                    EnableSetValueCommand = false,
                };
                if (string.IsNullOrEmpty(sqlSessionManagerSettings.ConnectionString))
                {
                    sqlSessionManagerSettings.ConnectionString = connectionString;
                }

                return(new FeatureFlagsSettings(featureFlagAssemblies)
                {
                    ConnectionString = connectionString,
                    InitializationConnectionString = initializationConnectionString,
                    SqlSessionManagerSettings = sqlSessionManagerSettings,
                });
            });

            return(services);
        }
        /// <summary><para>Register RimDev Feature Flags in the dependency system.</para>
        /// <para>The <see cref="IFeatureManagerSnapshot"/> implementation must be registered in order to
        /// construct individual <see cref="Feature"/> instances.</para>
        /// </summary>
        /// <param name="services"><see cref="IServiceCollection"/></param>
        /// <param name="configuration"><see cref="IConfiguration"/></param>
        /// <param name="featureFlagAssemblies">A list of assemblies to scan for classes inheriting from
        /// <see cref="Feature"/>.</param>
        /// <param name="connectionString">Connection string for SELECT/INSERT/DELETE operations.</param>
        /// <param name="initializationConnectionString">Connection string for the CREATE TABLE operation.</param>
        /// <param name="sqlSessionManagerSettings">Optional <see cref="SqlSessionManagerSettings"/></param>
        /// <returns><see cref="IServiceCollection"/></returns>
        /// <exception cref="Exception">When the connection strings are missing/empty.</exception>
        public static IServiceCollection AddRimDevFeatureFlags(
            this IServiceCollection services,
            IConfiguration configuration,
            ICollection <Assembly> featureFlagAssemblies,
            string connectionString,
            string initializationConnectionString,
            SqlSessionManagerSettings sqlSessionManagerSettings = null
            )
        {
            services.AddFeatureFlagSettings(
                configuration,
                featureFlagAssemblies: featureFlagAssemblies,
                connectionString: connectionString,
                initializationConnectionString: initializationConnectionString,
                sqlSessionManagerSettings: sqlSessionManagerSettings
                );
            services.AddStronglyTypedFeatureFlags(
                featureFlagAssemblies: featureFlagAssemblies
                );
            services.AddFeatureFlagsSessionManager();

            return(services);
        }