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

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

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

以下是针对视图所有模板共同生成的源码:

<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" CompilerVersion="v3.5" Description="Template description here." %>
<%-- SchemaExplorer --%>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%-- 添加源数据库属性 --%>
<%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema"  DeepLoad="True" Optional="False" Category="01. Required" Description="Database" %>
<%@ Property Name="vName" Type="ViewSchema"  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="bGenOne" Type="Boolean" Category="Context"  Description="Generate One Template Or All"%>

<%-- 指明Template的来源 --%>
<%@ Register Name="view_BLLTemplate" Template="view_BLL_General.cst" MergeProperties="Flase" ExcludeProperties=""%>
<%@ Register Name="view_IDALTemplate" Template="view_IDAL_General.cst" MergeProperties="Flase" ExcludeProperties=""%>
<%@ Register Name="view_SQLServerDALTemplate" Template="view_SQLServerDAL_General.cst" MergeProperties="Flase" ExcludeProperties=""%>
<%@ Register Name="view_ModelTemplate" Template="view_Model_General.cst" MergeProperties="Flase" ExcludeProperties=""%>




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

this.GenerateClasses(new view_BLLTemplate(), vName, "BLL\", bGenOne); Response.Write("Generate view_BLL Classes Done!\n\n");

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

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

this.GenerateClasses(new view_SQLServerDALTemplate(), vName, "SQLServerDAL\", bGenOne); Response.Write("Generate view_SQLServerDAL Classes Done!\n\n");

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

Debug.WriteLine("OK"); %>