ASP.NET三层架构源码(CodeSmith版)之七:Table-所有模板生成

动软代码生成器生成的ASP.NET三层架构代码比较规范,是学习ASP.NET的好例子

此三层架构改造自动软的工厂模式模板,使用CodeSmith进行重写,以方便大家修改模板文件

以下是针对表格的所有模板同时生成的源码:

<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" CompilerVersion="v3.5" Description="生成所有模板文件" %>
<%-- SchemaExplorer --%>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%-- 添加源数据库属性 --%>
<%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema"  DeepLoad="True" Optional="False" Category="01. Required" Description="Database" %>
<%@ Property Name="tName" Type="TableSchema"  DeepLoad="True" Optional="True" Category="01. Required" Description="TableName" %>

<%@ Property Name="Namespace" Type="String" Category="Context" Description="NameSpace"%>  
<%@ Property Name="Author" Type="String" Category="Context"  Description="Author" Default="chenr"%>  
<%@ Property Name="TablePrefix" Type="System.String" Default="T" Category="Context" Description="The prefix to remove from table names" %>  
<%@ Property Name="bGenOne" Type="Boolean" Category="Context"  Description="Generate One Template Or All"%>

<%-- 指明Template的来源 --%>
<%@ Register Name="BLLTemplate" Template="BLL_General.cst" MergeProperties="Flase" ExcludeProperties=""%>
<%@ Register Name="IDALTemplate" Template="IDAL_General.cst" MergeProperties="Flase" ExcludeProperties=""%>
<%@ Register Name="SQLServerDALTemplate" Template="SQLServerDAL_General.cst" MergeProperties="Flase" ExcludeProperties=""%>
<%@ Register Name="ModelTemplate" Template="Model_General.cst" MergeProperties="Flase" ExcludeProperties=""%>



<% Response.Write("Generating ... ...\n\n");

this.GenerateClasses(new BLLTemplate(), tName, "BLL\", bGenOne); Response.Write("Generate BLL Classes Done!\n\n");

this.GenerateClasses(new IDALTemplate(), tName, "IDAL\I", bGenOne); Response.Write("Generate IDAL Classes Done!\n\n");

this.GenerateClasses(new ModelTemplate(), tName, "Model\m", bGenOne); Response.Write("Generate Model Classes Done!\n\n");

this.GenerateClasses(new SQLServerDALTemplate(), tName, "SQLServerDAL\", bGenOne); Response.Write("Generate SQLServerDAL Classes Done!\n\n");

Response.Write("ALL Done!\n\n"); Response.Write("ALL File in : " + OutputDirectory);

Debug.WriteLine("OK"); %>