添加项目文件。
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using Autofac;
|
||||
using MongoRepository;
|
||||
|
||||
namespace CommonInfrastructure
|
||||
{
|
||||
public class AutofacModule : Module
|
||||
{
|
||||
protected override void Load(ContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterGeneric(typeof(MongoBaseRepository<>))
|
||||
.As(typeof(IMongoBaseRepository<>))
|
||||
.InstancePerLifetimeScope();
|
||||
|
||||
builder.RegisterType<RedisService.RedisService>()
|
||||
.As<RedisService.IRedisService>()
|
||||
.InstancePerLifetimeScope();
|
||||
}
|
||||
|
||||
public static void RegisterServices(ContainerBuilder builder, Type serviceAssemblyType)
|
||||
{
|
||||
builder.RegisterAssemblyTypes(serviceAssemblyType.Assembly)
|
||||
.Where(t => t.Name.EndsWith("Service"))
|
||||
.AsImplementedInterfaces()
|
||||
.InstancePerLifetimeScope();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user