修改接口时间

This commit is contained in:
2022-11-22 09:00:49 +08:00
parent 65e478bb35
commit 7bda924bf1
7 changed files with 307 additions and 35 deletions
@@ -11,7 +11,10 @@ using System.Linq;
using System.Reflection;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
using MediatR;
using IRaCIS.Application.Services;
using IRaCIS.Application.Interfaces;
using AutoMapper;
namespace IRaCIS.Core.API
{
@@ -26,8 +29,12 @@ namespace IRaCIS.Core.API
containerBuilder.RegisterGeneric(typeof(Repository<>))
.As(typeof(IRepository<>)).InstancePerLifetimeScope();//注册泛型仓储
containerBuilder.RegisterGeneric(typeof(EFUnitOfWork<>))
.As(typeof(IEFUnitOfWork<>)).InstancePerLifetimeScope();//注册仓储
containerBuilder.RegisterType<Repository>().As<IRepository>().InstancePerLifetimeScope();
//containerBuilder.RegisterType<Mapper>().As<IMapper>().InstancePerLifetimeScope();
//containerBuilder.RegisterGeneric(typeof(EFUnitOfWork<>))
// .As(typeof(IEFUnitOfWork<>)).InstancePerLifetimeScope();//注册仓储
#endregion
@@ -38,29 +45,30 @@ namespace IRaCIS.Core.API
.Where(type => typeof(IDynamicWebApi).IsAssignableFrom(type))
.PropertiesAutowired();
//var controllerBaseType = typeof(ControllerBase);
//containerBuilder.RegisterAssemblyTypes(typeof(BaseService).Assembly)
// .Where(t => controllerBaseType.IsAssignableFrom(t) && t != controllerBaseType)
// .PropertiesAutowired();
#endregion
//containerBuilder.RegisterType<BaseService>().As<IBaseService>().PropertiesAutowired().InstancePerLifetimeScope();
//containerBuilder.RegisterType<DictionaryService>().As<IDictionaryService>().InstancePerLifetimeScope();
Assembly application = Assembly.LoadFrom(AppDomain.CurrentDomain.BaseDirectory + "IRaCIS.Core.Application.dll");
containerBuilder.RegisterAssemblyTypes(application).Where(t => t.FullName.Contains("Service"))
.PropertiesAutowired().AsImplementedInterfaces().EnableClassInterceptors();
Assembly infrastructure = Assembly.Load("IRaCIS.Core.Infra.EFCore");
containerBuilder.RegisterAssemblyTypes(infrastructure).AsImplementedInterfaces();
//Assembly infrastructure = Assembly.Load("IRaCIS.Core.Infra.EFCore");
//containerBuilder.RegisterAssemblyTypes(infrastructure).AsImplementedInterfaces();
containerBuilder.RegisterType<HttpContextAccessor>().As<IHttpContextAccessor>().SingleInstance();
containerBuilder.RegisterType<UserInfo>().As<IUserInfo>().InstancePerLifetimeScope();
//containerBuilder.RegisterType<Dictionary>().InstancePerLifetimeScope();
//Autofac 注册拦截器 需要注意的是生成api上服务上的动态代理AOP失效 间接掉用不影响
containerBuilder.RegisterType<TrialStatusAutofacAOP>();
//containerBuilder.RegisterType<TrialStatusAutofacAOP>();
//containerBuilder.RegisterType<UserAddAOP>();
//containerBuilder.RegisterType<QANoticeAOP>();
//containerBuilder.RegisterType<LogService>().As<ILogService>().SingleInstance();