HyperDAL 代码生成器 HyperDTT 一个模板示例
2005-08-28 11:29
330 查看
以下是 HyperDAL 代码生成器模板中的一个模板示例。
在这个示例中,展现了 HyperDTT 是如何将 Smartsoft.HyperDAL.dll 程序集的 tableMap 对象注入到模板中和模板是如何操作注入的 tableMap 对象来完成模板翻译工作的。
<%@ template kind='script' %>
<%@ template language="cs" %>
<%@ template references="Smartsoft.HyperDAL.dll" %>
<%@ template imports="Smartsoft.HyperDAL" %>
<%
string appNamespace = DTTDomain[ "APP_NAMESPACE" ] as string;
TableMap tableMap = DTTInput[ "TABLE_MAP" ] as TableMap;
int index = 0;
int count = tableMap.ColumnMaps.Count;
%>
using System;
namespace <%=appNamespace%>
{
/// <summary>
/// Summary description for <%=tableMap.TokenName%>BusinessObject.
/// </summary>
public class <%=tableMap.TokenName%>BusinessObject
{
public <%=tableMap.TokenName%>BusinessObject()
{
}
<%
for( index = 0; index < count; index++ )
{
ColumnMap cm = tableMap.ColumnMaps[ index ];
string start = new string( cm.Caption[ 0 ], 1 );
string fieldName = start.ToLower() + cm.Caption.Substring( 1 );
string attrName = start.ToUpper() + cm.Caption.Substring( 1 );
%>
private <%=cm.DataType%> _<%=fieldName%>;
public <%=cm.DataType%> <%=attrName%>
{
get{ return( _<%=fieldName%> ); }
set{ _<%=fieldName%> = value; }
}
<%
if( index < count - 1 )
{
%>
<%
}
}
%>
}
}
在这个示例中,展现了 HyperDTT 是如何将 Smartsoft.HyperDAL.dll 程序集的 tableMap 对象注入到模板中和模板是如何操作注入的 tableMap 对象来完成模板翻译工作的。
<%@ template kind='script' %>
<%@ template language="cs" %>
<%@ template references="Smartsoft.HyperDAL.dll" %>
<%@ template imports="Smartsoft.HyperDAL" %>
<%
string appNamespace = DTTDomain[ "APP_NAMESPACE" ] as string;
TableMap tableMap = DTTInput[ "TABLE_MAP" ] as TableMap;
int index = 0;
int count = tableMap.ColumnMaps.Count;
%>
using System;
namespace <%=appNamespace%>
{
/// <summary>
/// Summary description for <%=tableMap.TokenName%>BusinessObject.
/// </summary>
public class <%=tableMap.TokenName%>BusinessObject
{
public <%=tableMap.TokenName%>BusinessObject()
{
}
<%
for( index = 0; index < count; index++ )
{
ColumnMap cm = tableMap.ColumnMaps[ index ];
string start = new string( cm.Caption[ 0 ], 1 );
string fieldName = start.ToLower() + cm.Caption.Substring( 1 );
string attrName = start.ToUpper() + cm.Caption.Substring( 1 );
%>
private <%=cm.DataType%> _<%=fieldName%>;
public <%=cm.DataType%> <%=attrName%>
{
get{ return( _<%=fieldName%> ); }
set{ _<%=fieldName%> = value; }
}
<%
if( index < count - 1 )
{
%>
<%
}
}
%>
}
}
相关文章推荐
- HyperDAL 代码生成器引擎 HyperDTT 简介
- 一个基于velocity模板引擎的代码生成器
- T4模板——一个神奇的代码生成器
- 一个简单的类模板的友元函数和友元类示例
- 蛙蛙推荐:用脚本写一个支持模板的代码生成器
- 模板编写的一个示例
- CodeSmith是一个基于模板的代码生成器
- [Hyper-V]制作一个干净的操作系统模板
- 类模板作为函数参数以及作为类模板参数的一个简单示例
- C#泛型与委托:一个简单的数组模板示例
- 一个超级简单的HTML模板框架源代码以及使用示例
- 创建一个优质可用的Hyper-V虚拟机模板
- 一个c++模板示例
- 一个简单的代码生成器(T4文本模板运用)
- 最大似然估计的一个示例
- 根据juery CSS点击一个标签弹出一个遮罩层的简单示例
- 一个完整的对日期、金额格式化的标签及使用示例
- 示例 - 17行代码实现一个简单高效的多线程蜘蛛程序
- 代码重构的一个示例