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().As().SingleInstance(); builder.RegisterType().As().SingleInstance(); builder.RegisterType().PropertiesAutowired(); //builder.RegisterType().PropertiesAutowired(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType(typeof(DomainServiceBase)).As(typeof(IDomainService)).InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerLifetimeScope() .PropertiesAutowired(); //builder.RegisterType().As().InstancePerLifetimeScope() // .PropertiesAutowired(); builder.RegisterType(); Assembly service = Assembly.Load("APT.API"); //Assembly iservice = Assembly.Load("APT.API.IService"); builder.RegisterAssemblyTypes(service).AsImplementedInterfaces() .InstancePerLifetimeScope() .EnableInterfaceInterceptors().InterceptedBy(typeof(LogInterceptor)); } } }