1
我开始调查T4代码生成。如何在T4 ClassBlock方法中使用模板?
我得到你可以在其中嵌入的C#/可进行巧妙的东西VB小块的一个基本的模板...
<#@ template language="VB" debug="True" hostspecific="True" #>
<#@ output extension=".vb" debug="True" hostspecific="True" #>
Imports System
<#For Each Table as String in New String(0 {"Table1","Table2"}#>
Public Class <#=Table#>DA
Public Sub New
<#= WriteConstructorBody() #>
End Sub
End Class
<#Next#>
<#+
Public Function WriteConstructorBody() as String
return "' Some comment"
End function
#>
这是伟大的。但是我想能够写我的主块这样......
<#@ template language="VB" debug="True" hostspecific="True" #>
<#@ output extension=".vb" debug="True" hostspecific="True" #>
Imports System
<#
For Each BaseTableName as String in New String(){"Table1","Table2"}
WriteRecDataInterface(BaseTableName)
WriteRecDataClass(BaseTableName)
WriteDAInterface(BaseTableName)
WriteDAClass(BaseTableName)
Next
#>
然后我想能够有方法的类块存在WriteX但自己使用的代码通过实例即逃脱代码块是可写的。
我该如何做到这一点?
我不得不看很难找到你的榜样静态文本....我的<# =东西是令人困惑的事情。 – 2008-10-15 11:24:13