using JiShe.CollectBus.Cassandra;
using Volo.Abp;
using Volo.Abp.Modularity;

// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.DependencyInjection
{
    public static class ApplicationInitializationContextExtensions
    {
        public static async Task UseCassandra(this ApplicationInitializationContext context)
        {
            var service = context.ServiceProvider;
            var cassandraProvider = service.GetRequiredService<ICassandraProvider>();
            await cassandraProvider.InitClusterAndSessionAsync();
        }
    }

    public static class ServiceCollectionExtensions
    {
        public static void AddCassandra(this ServiceConfigurationContext context)
        {
            context.Services.AddTransient(typeof(ICassandraRepository<,>), typeof(CassandraRepository<,>));
        }
    }
}
