基本完善前端框架,发现后端bug

This commit is contained in:
橙子
2021-10-15 20:33:08 +08:00
parent 141987893e
commit cbfb19ade8
24 changed files with 352 additions and 318 deletions

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
@@ -21,19 +22,19 @@ namespace Yi.Framework.ApiMicroservice.Utility
{
protected override void Load(ContainerBuilder containerBuilder)
{
//var assembly = this.GetType().GetTypeInfo().Assembly;
//var builder = new ContainerBuilder();
//var manager = new ApplicationPartManager();
//manager.ApplicationParts.Add(new AssemblyPart(assembly));
//manager.FeatureProviders.Add(new ControllerFeatureProvider());
//var feature = new ControllerFeature();
//manager.PopulateFeature(feature);
//builder.RegisterType<ApplicationPartManager>().AsSelf().SingleInstance();
//builder.RegisterTypes(feature.Controllers.Select(ti => ti.AsType()).ToArray()).PropertiesAutowired();
//containerBuilder.RegisterType<TestServiceA>().As<ITestServiceA>().InstancePerDependency(); 瞬态
//containerBuilder.RegisterType<TestServiceB>().As<ITestServiceB>().SingleInstance(); 单例
//containerBuilder.RegisterType<TestServiceC>().As<ITestServiceC>().InstancePerLifetimeScope(); 作用域
var basePath = AppContext.BaseDirectory;
var servicesDllFile = Path.Combine(basePath, "Yi.Framework.Service.dll");
if (!(File.Exists(servicesDllFile)))
{
var msg = "service.dll 丢失,请编译后重新生成。";
throw new Exception(msg);
}
var assemblysServices = Assembly.LoadFrom(servicesDllFile);
containerBuilder.RegisterAssemblyTypes(assemblysServices)
.AsImplementedInterfaces()
.InstancePerDependency()
.EnableInterfaceInterceptors();
containerBuilder.Register(c => new CustomAutofacAop());//AOP注册
//containerBuilder.RegisterType<A>().As<IA>().EnableInterfaceInterceptors();开启Aop
@@ -41,10 +42,9 @@ namespace Yi.Framework.ApiMicroservice.Utility
//将数据库对象注入
//containerBuilder.RegisterType<DataContext>().As<DbContext>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerLifetimeScope().EnableInterfaceInterceptors();
//containerBuilder.RegisterGeneric(typeof(BaseService<>)).As(typeof(IBaseService<>)).InstancePerDependency().EnableInterfaceInterceptors();
containerBuilder.RegisterType<UserService>().As< IUserService >().InstancePerLifetimeScope().EnableInterfaceInterceptors();
containerBuilder.RegisterType<RoleService>().As<IRoleService>().InstancePerLifetimeScope().EnableInterfaceInterceptors();
}