您的位置:首页 > 编程语言

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 )
    {
%>
   
<%
    }
  }
%>
  }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息