This commit is contained in:
454313500@qq.com
2021-03-21 02:13:08 +08:00
parent 367f8f8830
commit 1ecb92df33
7 changed files with 49 additions and 4 deletions

View File

@@ -5,6 +5,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="6.1.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@@ -1,3 +1,4 @@
using Autofac.Extensions.DependencyInjection;
using CC.Yi.DAL;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@@ -38,6 +39,6 @@ namespace CC.Yi.API
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}).UseServiceProviderFactory(new AutofacServiceProviderFactory());
}
}

View File

@@ -1,5 +1,8 @@
using Autofac;
using Autofac.Extras.DynamicProxy;
using CC.Yi.BLL;
using CC.Yi.Common.Castle;
using CC.Yi.DAL;
using CC.Yi.IBLL;
using CC.Yi.IDAL;
@@ -45,8 +48,18 @@ namespace CC.Yi.API
{
options.UseSqlServer(connection, b => b.MigrationsAssembly("CC.Yi.API"));//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
});
services.AddScoped(typeof(IBaseDal<>), typeof(BaseDal<>));
services.AddScoped(typeof(IstudentBll), typeof(studentBll));
//<2F><><EFBFBD><EFBFBD>ע<EFBFBD><D7A2>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>Autofac
//services.AddScoped(typeof(IBaseDal<>), typeof(BaseDal<>));
//services.AddScoped(typeof(IstudentBll), typeof(studentBll));
}
//<2F><>̬ <20><><EFBFBD><EFBFBD>AOP˼<50><CBBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><D7A2> Autofac
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterType(typeof(CustomAutofacAop));
builder.RegisterGeneric(typeof(BaseDal<>)).As(typeof(IBaseDal<>)) ;
builder.RegisterType<studentBll>().As<IstudentBll>().EnableInterfaceInterceptors();//<2F><>ʾע<CABE><D7A2>ǰ<EFBFBD><C7B0>Ҫִ<D2AA><D6B4>Castle
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.