コード例 #1
0
        public static IServiceCollection AddLiteDbStorageInfrastructure(this IServiceCollection serviceCollection, Action <LiteDbConfiguration> configure)
        {
            var config = new LiteDbConfiguration();

            configure(config);

            return(serviceCollection.AddLiteDbStorageInfrastructure(config));
        }
コード例 #2
0
        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)));
        }
コード例 #3
0
 private static IServiceCollection AddLiteDbStorageInfrastructure(this IServiceCollection serviceCollection, LiteDbConfiguration config)
 {
     return(serviceCollection.AddSingleton <IStorageInfrastructure>(r =>
                                                                    new Storage(CreateLiteDbConnection(config))));
 }