/// <summary> /// Add components for constructing tenant-specific blob storage containers. /// </summary> /// <param name="services">The target service collection.</param> /// <param name="getOptions">Function to get the configuration options.</param> /// <returns>The service collection.</returns> public static IServiceCollection AddTenantSqlConnectionFactory( this IServiceCollection services, Func <IServiceProvider, TenantSqlConnectionFactoryOptions> getOptions) { ArgumentNullException.ThrowIfNull(services); if (services.Any(s => typeof(ITenantSqlConnectionFactory).IsAssignableFrom(s.ServiceType))) { return(services); } services.AddSingleton <ITenantSqlConnectionFactory>(s => { TenantSqlConnectionFactoryOptions options = getOptions(s); return(new TenantSqlConnectionFactory(options)); }); return(services); }
/// <summary> /// Adds services required by tenanted SQL Server based stores. /// </summary> /// <param name="services">The service collection.</param> /// <param name="options">Configuration for the TenantCloudBlobContainerFactory.</param> /// <returns>The modified service collection.</returns> public static IServiceCollection AddTenantSqlConnectionFactory( this IServiceCollection services, TenantSqlConnectionFactoryOptions options) { return(services.AddTenantSqlConnectionFactory(_ => options)); }