2021-03-20 14:12:24 +08:00
|
|
|
|
<#@ template debug="false" hostspecific="true" language="C#" #>
|
|
|
|
|
|
<#@ assembly name="System.Core" #>
|
|
|
|
|
|
<#@ import namespace="System.Linq" #>
|
|
|
|
|
|
<#@ import namespace="System.Text" #>
|
|
|
|
|
|
<#@ import namespace="System.Collections.Generic" #>
|
|
|
|
|
|
<#@ import namespace="System.IO" #>
|
|
|
|
|
|
<#@ output extension=".cs" #>
|
|
|
|
|
|
<#
|
|
|
|
|
|
string solutionsPath = Host.ResolveAssemblyReference("$(SolutionDir)");//获取解决方案路径
|
|
|
|
|
|
string txt;
|
|
|
|
|
|
StreamReader sr = new StreamReader(solutionsPath+@"\T4Model\T4Model.txt");
|
|
|
|
|
|
txt=sr.ReadToEnd();
|
|
|
|
|
|
sr.Close();
|
|
|
|
|
|
string[] ModelData= txt.Split(',');
|
|
|
|
|
|
#>
|
2021-05-13 01:39:34 +08:00
|
|
|
|
using Autofac;
|
|
|
|
|
|
using Autofac.Extras.DynamicProxy;
|
|
|
|
|
|
using CC.Yi.BLL;
|
|
|
|
|
|
using CC.Yi.Common.Castle;
|
2021-03-20 14:12:24 +08:00
|
|
|
|
using CC.Yi.DAL;
|
2021-05-13 01:39:34 +08:00
|
|
|
|
using CC.Yi.IBLL;
|
2021-03-20 14:12:24 +08:00
|
|
|
|
using CC.Yi.IDAL;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
2021-05-13 01:39:34 +08:00
|
|
|
|
|
|
|
|
|
|
namespace CC.Yi.API
|
2021-03-20 14:12:24 +08:00
|
|
|
|
{
|
2021-05-13 01:39:34 +08:00
|
|
|
|
public partial class Startup
|
2021-03-20 14:12:24 +08:00
|
|
|
|
{
|
2021-05-13 01:39:34 +08:00
|
|
|
|
//动态 面向AOP思想的依赖注入 Autofac
|
|
|
|
|
|
public void ConfigureContainer(ContainerBuilder builder)
|
2021-03-20 14:12:24 +08:00
|
|
|
|
{
|
2021-05-13 01:39:34 +08:00
|
|
|
|
builder.RegisterType(typeof(CustomAutofacAop));
|
|
|
|
|
|
builder.RegisterGeneric(typeof(BaseDal<>)).As(typeof(IBaseDal<>));
|
|
|
|
|
|
<# foreach(string k in ModelData){#>
|
|
|
|
|
|
builder.RegisterType<<#=k #>Bll>().As<I<#=k #>Bll>().EnableInterfaceInterceptors();//表示注入前后要执行Castle,AOP
|
2021-03-20 14:12:24 +08:00
|
|
|
|
<# } #>
|
2021-05-13 01:39:34 +08:00
|
|
|
|
}
|
2021-03-20 14:12:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|