ITextTemplatingEngineHost.ProvideTemplatingAppDomain 方法
提供應用程式定義域,以執行產生的轉換類別。
命名空間: Microsoft.VisualStudio.TextTemplating
組件: Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (在 Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll 中)
語法
'宣告
Function ProvideTemplatingAppDomain ( _
content As String _
) As AppDomain
AppDomain ProvideTemplatingAppDomain(
string content
)
AppDomain^ ProvideTemplatingAppDomain(
String^ content
)
abstract ProvideTemplatingAppDomain :
content:string -> AppDomain
function ProvideTemplatingAppDomain(
content : String
) : AppDomain
參數
- content
型別:System.String
要處理的文字範本檔內容。
傳回值
型別:System.AppDomain
AppDomain ,會編譯並執行產生的轉換類別。
備註
主應用程式可以使用 content 參數,根據要進行處理的文字範本檔案來提供特定的 AppDomain。例如,如果要重複處理相同的文字範本檔案,主應用程式可以快取 AppDomain。如果主應用程式不需要此資訊,則主應用程式可以忽略 content 參數。
範例
下列程式碼範例示範自訂主機可能的實作。這個程式碼是完整範例的一部分。如需完整的範例,請參閱 逐步解說:建立自訂文字範本主機。
public AppDomain ProvideTemplatingAppDomain(string content)
{
//this host will provide a new application domain each time the
//engine processes a text template
//-------------------------------------------------------------
return AppDomain.CreateDomain("Generation App Domain");
//this could be changed to return the current appdomain, but new
//assemblies are loaded into this AppDomain on a regular basis
//if the AppDomain lasts too long, it will grow indefintely
//which might be regarded as a leak
//this could be customized to cache the application domain for
//a certain number of text template generations (for example 10)
//this could be customized based on the contents of the text
//template, which are provided as a parameter for that purpose
}
Public Function ProvideTemplatingAppDomain(ByVal content As String) As System.AppDomain Implements Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.ProvideTemplatingAppDomain
'this host will provide a new application domain each time the
'engine processes a text template
'-------------------------------------------------------------
Return AppDomain.CreateDomain("Generation App Domain")
'this could be changed to return the current application domain, but new
'assemblies are loaded into this application domain on a regular basis
'if the application domain lasts too long, it will grow indefintely
'which might be regarded as a leak
'this could be customized to cache the application domain for
'a certain number of text template generations (for example 10)
'this could be customized based on the contents of the text
'template, which are provided as a parameter for that purpose
End Function
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualStudio.TextTemplating 命名空間