指令為文字範本轉換引擎提供指示。
指令的語法如下:
<#@ DirectiveName [AttributeName = "AttributeValue"] ... #>
所有屬性值都必須以雙引號括住。 如果值本身包含引號,則必須以 \ 字元逸出引號。
指引通常是範本檔案或併入檔案中的第一個元素。 您不應該將它們放在程式碼區塊 <#...#>中,也不應該放在類別功能區塊 <#+...#>之後。
<#@ template [language="VB"] [hostspecific="true|TrueFromBase"] [debug="true"] [inherits="templateBaseClass"] [culture="code"] [compilerOptions="options"] [visibility="internal"] [linePragmas="false"] #>
<#@ parameter type="Full.TypeName" name="ParameterName" #>
<#@ output extension=".fileNameExtension" [encoding="encoding"] #>
<#@ assembly name="[assembly strong name|assembly file name]" #>
<#@ import namespace="namespace" #>
<#@ include file="filePath" #>
<#@ CleanupBehavior processor="T4VSHost" CleanupAfterProcessingtemplate="true" #>
此外,您可以建立自己的指令。 如需詳細資訊,請參考 建立自訂 T4 文字模板指令處理器。 如果您使用視覺化和建模 SDK 來建立網域特定語言 (DSL),則會產生指令處理器作為 DSL 的一部分。