共用方式為


ModelBusEnabledTextTransformation 類別

若要存取文字範本程式碼中的 Visual Studio ModelBus,請在範本之 template 指示詞的 inherits 屬性中指定這個類別,並將 hostspecific 屬性設為 true。 在範本程式碼中,您可以取得 SModelBus 和 SComponentModel 服務。

繼承階層架構

System.Object
  Microsoft.VisualStudio.TextTemplating.TextTransformation
    Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation
      Microsoft.VisualStudio.TextTemplating.Modeling.ModelBusEnabledTextTransformation

命名空間:  Microsoft.VisualStudio.TextTemplating.Modeling
組件:  Microsoft.VisualStudio.TextTemplating.Modeling.10.0 (在 Microsoft.VisualStudio.TextTemplating.Modeling.10.0.dll 中)

語法

'宣告
Public MustInherit Class ModelBusEnabledTextTransformation _
    Inherits ModelingTextTransformation
public abstract class ModelBusEnabledTextTransformation : ModelingTextTransformation
public ref class ModelBusEnabledTextTransformation abstract : public ModelingTextTransformation
[<AbstractClass>]
type ModelBusEnabledTextTransformation =  
    class
        inherit ModelingTextTransformation
    end
public abstract class ModelBusEnabledTextTransformation extends ModelingTextTransformation

ModelBusEnabledTextTransformation 型別會公開下列成員。

建構函式

  名稱 說明
受保護的方法 ModelBusEnabledTextTransformation

回頁首

屬性

  名稱 說明
公用屬性 CurrentIndent 取得目前縮排文字,這個文字是每行所產生之文字輸出都有前置文字。 (繼承自 TextTransformation)。
公用屬性 Errors 基礎架構。取得文字範本轉換程序的錯誤集合。 (繼承自 TextTransformation)。
受保護的屬性 GenerationEnvironment 取得或設定字串,文字範本轉換程序會使用這個字串來組合產生的文字輸出。 (繼承自 TextTransformation)。
受保護的屬性 ModelBus 取得這個基底類別所提供的 Visual Studio ModelBus 服務。
受保護的屬性 ServiceProvider , 包含 Visual Studio ModelBus 的服務提供者。不使用主機的服務提供者。 (覆寫 ModelingTextTransformation.ServiceProvider。)
公用屬性 Session (繼承自 ModelingTextTransformation)。
受保護的屬性 SkipValidation 如果為 true,ValidateStore() 不會執行驗證並且會傳回 false。預設值為 false。 (繼承自 ModelingTextTransformation)。
受保護的屬性 Store 取得模型存放區。 (繼承自 ModelingTextTransformation)。

回頁首

方法

  名稱 說明
受保護的方法 AddDomainModel 加入要供存放區載入的網域模型型別。在呼叫 Initialize() 之前,請先針對每個網域模型呼叫此項目。 (繼承自 ModelingTextTransformation)。
公用方法 ClearIndent CurrentIndent 重設為空字串。 (繼承自 TextTransformation)。
公用方法 Dispose() 釋放 TextTransformation 所使用的所有資源。 (繼承自 TextTransformation)。
受保護的方法 Dispose(Boolean) (繼承自 ModelingTextTransformation)。
公用方法 Equals 判斷指定的 Object 和目前的 Object 是否相等。 (繼承自 Object)。
公用方法 Error 建立新錯誤,以儲存在文字範本轉換程序期間發生的錯誤資訊。 (繼承自 TextTransformation)。
受保護的方法 Finalize 允許 Object 在記憶體回收行程予以回收之前,嘗試釋放資源並執行其他清除作業。由記憶體回收行程所呼叫。 (繼承自 TextTransformation)。
公用方法 GetHashCode 做為特定型別的雜湊函式。 (繼承自 Object)。
公用方法 GetType 取得目前執行個體的 Type。 (繼承自 Object)。
公用方法 Initialize 使用 AddModel() 載入指定的模型,讓主應用程式準備好要處理範本。 (繼承自 ModelingTextTransformation)。
受保護的方法 MemberwiseClone 建立目前 Object 的淺層複本 (Shallow Copy)。 (繼承自 Object)。
受保護的方法 OnSessionChanged 每當提供的工作階段與最後一個記住的工作階段不同時呼叫。清除靜態 modelbus 執行個體,以準備讀取模型檔案的新快照。 (覆寫 ModelingTextTransformation.OnSessionChanged(ITextTemplatingSession, ITextTemplatingSession)。)
公用方法 PopIndent CurrentIndent 中移除最新加入的文字。 (繼承自 TextTransformation)。
公用方法 PushIndent 將文字加入至 CurrentIndent,這個文字是每行所產生之文字輸出都有的前置文字。 (繼承自 TextTransformation)。
受保護的方法 ReportError 將 ModelBus 錯誤轉換為文字範本錯誤。根據分類值呼叫 this.Error 或 this.Warning。
公用方法 ToString 傳回表示目前物件的字串。 (繼承自 Object)。
公用方法 TransformText 在衍生類別中覆寫時,會產生轉換的文字輸出。 (繼承自 TextTransformation)。
受保護的方法 ValidateStore 使用指定的驗證分類來驗證存放區。如果有錯誤則會傳回 true。 (繼承自 ModelingTextTransformation)。
公用方法 Warning 建立新警告,以儲存在文字範本轉換程序期間發生的錯誤資訊。 (繼承自 TextTransformation)。
公用方法 Write(String) 將所指定字串的複本附加至產生的文字輸出。 (繼承自 TextTransformation)。
公用方法 Write(String, array<Object[]) 將格式化字串 (其中包含零個或更多格式規格) 附加至產生的文字輸出。每一個格式規格會由對應之物件引數的字串表示所取代。 (繼承自 TextTransformation)。
公用方法 WriteLine(String) 將所指定字串的複本和預設行結束字元附加至產生的文字輸出。 (繼承自 TextTransformation)。
公用方法 WriteLine(String, array<Object[]) 將格式化字串 (其中包含零個或更多格式規格) 和預設行結束字元附加至產生的文字輸出。每一個格式規格會由對應之物件引數的字串表示所取代。 (繼承自 TextTransformation)。

回頁首

備註

若要在範本中可使用此文字轉換,您必須在 template 指示詞中將 hostspecific 屬性設定為 true。

範例

<#@ template debug="false" hostspecific="true" language="C#" inherits="Microsoft.VisualStudio.TextTemplating.Modeling.ModelBusEnabledTextTransformation" #>
<#@ assembly name="Microsoft.VisualStudio.TextTemplating.Modeling.10.0.dll" #>
<#@ assembly name="Microsoft.VisualStudio.Modeling.Sdk.Integration.10.0.dll" #>
<#@ import namespace="Microsoft.VisualStudio.Modeling.Integration" #>
<#@ output extension=".txt" #>
<# IModelBus modelbus = this.ServiceProvider.GetService(typeof(SModelBus)) as IModelBus; 
...
#>

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

Microsoft.VisualStudio.TextTemplating.Modeling 命名空間