public static IServiceCollection ConfigureStorageLogicServices(this IServiceCollection services, StorageLogicOptions options) { services.AddDbContextPool <ConfigurationContext>(dbOptions => dbOptions.UseSqlServer(options.SqlConfigurationConnectionString)); services.AddSingleton <StorageLogicOptions>(options); services.AddSingleton <RuntimeCollections>(options.RuntimeCollections); services.AddSingleton <IMongoDatabase>(provider => { var connection = new MongoClient($"{options.MongoRuntimeConnectionString}"); return(connection.GetDatabase(options.MongoRuntimeDatabaseName)); }); services.AddTransient <IConfigurationStorage, ConfigurationStorage>(); services.AddTransient <IRuntimeStorage, RuntimeStorage>(); return(services); }
public static IWebHostBuilder UseStorageLogic(this IWebHostBuilder builder, StorageLogicOptions options) { return(builder.ConfigureServices(services => services.ConfigureStorageLogicServices(options))); }