Export (0) Print
Expand All

ITextTemplatingEngineHost.ProvideTemplatingAppDomain Method

Provides an application domain to run the generated transformation class.

Namespace: Microsoft.VisualStudio.TextTemplating
Assembly: Microsoft.VisualStudio.TextTemplating (in microsoft.visualstudio.texttemplating.dll)

AppDomain ProvideTemplatingAppDomain (
	string content
AppDomain ProvideTemplatingAppDomain (
	String content
function ProvideTemplatingAppDomain (
	content : String
) : AppDomain



The contents of the text template file to be processed.

Return Value

An AppDomain that is used to compile and execute the generated transformation class.

The host can use the content information to provide a specific AppDomain depending on the text template file to be processed. For example, the host could cache an AppDomain if the same text template file is being processed repeatedly. The host can choose to ignore the content parameter if it is not needed.

The following code example shows a possible implementation for a custom host. This code example is part of a larger example provided for the ITextTemplatingEngineHost interface.

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

Community Additions

© 2014 Microsoft