36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
|
|
using Autofac.Core;
|
|||
|
|
using Cassandra;
|
|||
|
|
using Cassandra.Mapping;
|
|||
|
|
using JiShe.CollectBus.Cassandra;
|
|||
|
|
using JiShe.CollectBus.Cassandra.Mappers;
|
|||
|
|
using Microsoft.Extensions.Options;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using Volo.Abp;
|
|||
|
|
using Volo.Abp.Modularity;
|
|||
|
|
|
|||
|
|
// ReSharper disable once CheckNamespace
|
|||
|
|
namespace Microsoft.Extensions.DependencyInjection
|
|||
|
|
{
|
|||
|
|
public static class ApplicationInitializationContextExtensions
|
|||
|
|
{
|
|||
|
|
public static void UseCassandra(this ApplicationInitializationContext context)
|
|||
|
|
{
|
|||
|
|
var service = context.ServiceProvider;
|
|||
|
|
var cassandraProvider = service.GetRequiredService<ICassandraProvider>();
|
|||
|
|
cassandraProvider.InitClusterAndSession();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static class ServiceCollectionExtensions
|
|||
|
|
{
|
|||
|
|
public static void AddCassandra(this ServiceConfigurationContext context)
|
|||
|
|
{
|
|||
|
|
context.Services.AddSingleton(typeof(ICassandraRepository<,>), typeof(CassandraRepository<,>));
|
|||
|
|
|
|||
|
|
var mappingConfig = new MappingConfiguration()
|
|||
|
|
.Define(new CollectBusMapping());
|
|||
|
|
context.Services.AddSingleton(mappingConfig);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|