模板是C#语法的 .cst文件

<%@ CodeTemplate Language="C#" TargetLanguage="Text" ResponseEncoding="UTF-8" Src="" Inherits="" Debug="False" CompilerVersion="v3.5" Description="Template description here." %>
<%@ Property Name="ModelClassNameSpace" Type="System.String" Default="ModelClassNameSpace" Optional="False" Category="Strings" Description="This is ModelClassNameSpace"%>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Windows.Forms.Design" %>
<%@ Import Namespace="System.Drawing.Design" %>
<%@ Import Namespace="System.IO" %>

<script runat="template">

private DatabaseSchema _sourceDatabase;
[Category("Database")]
[Description("This is a DatabaseSource")]
public DatabaseSchema SourceDatabase
{
    get{return this._sourceDatabase;}
    set{_sourceDatabase= value;}
}

//设置类文件名称
public string GetClassName(TableSchema table)
{
    //if (table.Name.EndsWith("s"))
    //{
        //return table.Name.Substring(0, table.Name.Length - 1) + "Entity";
    //}
    //else
    //{
    //    return table.Name+"Entity";
    //}
    return FormatTable(table.Name);
}
//格式化表名
public string FormatTable(string param)
{
	string[] p =param.Split('_');
	return p[p.Length-1].ToString();
}
</script>
<%
foreach(TableSchema table in _sourceDatabase.Tables)
{
    %>
    //<%=table.Description%>
    kernel.Bind<ADT.Eppendorf.IBLL.APP.I<%=FormatTable(table.Name)%>>().To<ADT.Eppendorf.BLL.APP.<%=FormatTable(table.Name)%>>();
    kernel.Bind<ADT.Eppendorf.IDAL.APP.I<%=FormatTable(table.Name)%>>().To<ADT.Eppendorf.DAL.APP.<%=FormatTable(table.Name)%>>();
    <%
}
%>

  

posted on 2016-03-02 13:43  邢帅杰  阅读(342)  评论(0编辑  收藏  举报