public static IServiceCollection AddLiteDbStorageInfrastructure(this IServiceCollection serviceCollection, Action <LiteDbConfiguration> configure) { var config = new LiteDbConfiguration(); configure(config); return(serviceCollection.AddLiteDbStorageInfrastructure(config)); }
private static ILiteDatabase CreateLiteDbConnection(LiteDbConfiguration config) { if (string.IsNullOrEmpty(config.ConnectionString)) { throw new ArgumentException("The connection string can't be null", nameof(config)); } return(new LiteDatabase(new ConnectionString(config.ConnectionString))); }
private static IServiceCollection AddLiteDbStorageInfrastructure(this IServiceCollection serviceCollection, LiteDbConfiguration config) { return(serviceCollection.AddSingleton <IStorageInfrastructure>(r => new Storage(CreateLiteDbConnection(config)))); }