提供运行所生成转换类的应用程序域。
命名空间: 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 命名空间