45 lines
1.8 KiB
C#
45 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Autofac;
|
|
using APT.Infrastructure.Core;
|
|
using APT.Infrastructure.EF;
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
using APT.Infrastructure.Core.Refctor;
|
|
using System.Reflection;
|
|
using Autofac.Extras.DynamicProxy;
|
|
using APT.Infrastructure.Api;
|
|
namespace APT.API
|
|
{
|
|
public static class DIConfig
|
|
{
|
|
public static void RegisterComponents(this ContainerBuilder builder)
|
|
{
|
|
ReflectHelper.GetClassMethodAttr(typeof(EfDbContext));
|
|
|
|
builder.RegisterType<EFDbContextLoggerProvider>().As<ILoggerProvider>().SingleInstance();
|
|
builder.RegisterType<LoggerFactory>().As<ILoggerFactory>().SingleInstance();
|
|
builder.RegisterType<EfDbContext>().PropertiesAutowired();
|
|
//builder.RegisterType<MigrationContext>().PropertiesAutowired();
|
|
|
|
builder.RegisterType<Repository>().As<IRepository>().InstancePerLifetimeScope();
|
|
builder.RegisterType<CommonService>().As<ICommonService>().InstancePerLifetimeScope();
|
|
|
|
builder.RegisterType(typeof(DomainServiceBase)).As(typeof(IDomainService)).InstancePerLifetimeScope();
|
|
builder.RegisterType<EfDbContext>().As<IUnitOfWork>().InstancePerLifetimeScope()
|
|
.PropertiesAutowired();
|
|
//builder.RegisterType<MigrationContext>().As<IUnitOfWork>().InstancePerLifetimeScope()
|
|
// .PropertiesAutowired();
|
|
|
|
builder.RegisterType<LogInterceptor>();
|
|
Assembly service = Assembly.Load("APT.API");
|
|
//Assembly iservice = Assembly.Load("APT.API.IService");
|
|
builder.RegisterAssemblyTypes(service).AsImplementedInterfaces()
|
|
.InstancePerLifetimeScope()
|
|
.EnableInterfaceInterceptors().InterceptedBy(typeof(LogInterceptor));
|
|
}
|
|
}
|
|
}
|