v1.0.2
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Autofac.Extras.DynamicProxy" Version="6.0.0" />
|
||||
<PackageReference Include="Castle.Core" Version="4.4.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
23
CC.Yi.Common/Castle/CustomAutofacAop.cs
Normal file
23
CC.Yi.Common/Castle/CustomAutofacAop.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Castle.DynamicProxy;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CC.Yi.Common.Castle
|
||||
{
|
||||
public class CustomAutofacAop : IInterceptor
|
||||
{
|
||||
public void Intercept(IInvocation invocation)
|
||||
{
|
||||
{
|
||||
|
||||
//这里写执行方法前
|
||||
}
|
||||
invocation.Proceed();//执行具体的实例
|
||||
{
|
||||
|
||||
//这里写执行方法后
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CC.Yi.Common\CC.Yi.Common.csproj" />
|
||||
<ProjectReference Include="..\CC.Yi.Model\CC.Yi.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using Autofac.Extras.DynamicProxy;
|
||||
using CC.Yi.Common.Castle;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace CC.Yi.IBLL
|
||||
{
|
||||
[Intercept(typeof(CustomAutofacAop))]
|
||||
public interface IBaseBll<T> where T : class, new()
|
||||
{
|
||||
#region
|
||||
|
||||
Reference in New Issue
Block a user