博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codesmith引用多个模板生成代码
阅读量:6712 次
发布时间:2019-06-25

本文共 1795 字,大约阅读时间需要 5 分钟。

<%--

Name:
Author:
Description:
--%>
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Src="" Inherits="" Debug="False" CompilerVersion="v3.5" Description="Template description here." %>
<%@ Register Name="EntityTemplate" Template="entity.cst" %>
<%@ Register Name="DAOTemplate" Template="dao.cst" %>
<%@ Register Name="BOTemplate" Template="bo.cst" %>
<%@ Property Name="Namespace" Type="System.String" Default="Beyondbit.App" Optional="True" Category="Strings" Description="This is a sample string property." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Property Name="SourceTables" Type="SchemaExplorer.TableSchemaCollection" Optional="False" Category="Required"%>

<%--= SampleStringProperty --%>

<% Start(); %>

<script runat="template">

public void GenerateEntity(SchemaExplorer.TableSchema table, EntityTemplate template) {

template.SourceTable = table;
template.NameSpace = Namespace + ".Entity";
template.RenderToFile(".\\" + template.NameSpace + "\\" + table.Name + ".cs", true);
}

public void GenerateDAO(SchemaExplorer.TableSchema table, DAOTemplate template) {

template.SourceTable = table;
template.NameSpace = Namespace + ".DAO";
template.RenderToFile(".\\" + template.NameSpace + "\\DAO" + table.Name + ".cs", true);
}

public void GenerateBO(SchemaExplorer.TableSchema table, BOTemplate template) {

template.SourceTable = table;
template.NameSpace = Namespace + ".BO";
template.RenderToFile(".\\" + template.NameSpace + "\\BO" + table.Name + ".cs", true);
}

public void Start() {

EntityTemplate tmpEntity = this.Create<EntityTemplate>();
DAOTemplate tmpDAO = this.Create<DAOTemplate>();
BOTemplate tmpBO = this.Create<BOTemplate>();
foreach (SchemaExplorer.TableSchema t in SourceTables){
GenerateEntity(t, tmpEntity);
GenerateDAO(t, tmpDAO);
GenerateBO(t, tmpBO);
}
}
</script>

转载地址:http://foxlo.baihongyu.com/

你可能感兴趣的文章
项目架构图,mvc架构图
查看>>
C语言错误 BUG报错整理
查看>>
java Pattern
查看>>
flink - accumulator
查看>>
高仿猫眼电影选座(选票)模块-b
查看>>
【转】iOS静态库 【.a 和framework】【超详细】
查看>>
Docker之Linux UnionFS
查看>>
基于 WebGL 3D 的 HTML5 档案馆可视化管理系统
查看>>
c#枚举转化示例大全,数字或字符串转枚举
查看>>
Java 性能优化 - Sun Hotspot JDK JVM 参数设置
查看>>
C++中单例模式对象的释放控制
查看>>
【你必须知道的.NET】:【大话String】
查看>>
android屏蔽返回键和home键
查看>>
Bash shell(五)-数据流重导向
查看>>
分享20个超酷的酒店类网站设计
查看>>
Ext.Net 1.2.0/Ext JS_用 Ext JS 遍历查找过滤检索 Ext.Net.Store 检索
查看>>
Apache CouchDB 1.2.0新特性
查看>>
更优美的javaScript(2)
查看>>
WCF服务编程 学习笔记(1)
查看>>
关于黑衣人3结尾时插曲K哼的歌名|Empire State Of Mind歌词中文翻译
查看>>