在這個示例中,展現(xiàn)了 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 )
{
%>
<%
}
}
%>
}
}