mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-03-25 19:26:37 +08:00
基本完善前端框架,发现后端bug
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user