Share via


ITextTemplatingEngineHost.ProvideTemplatingAppDomain (Método)

Proporciona un dominio de aplicación para ejecutar la clase de transformación generada.

Espacio de nombres:  Microsoft.VisualStudio.TextTemplating
Ensamblado:  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (en Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)

Sintaxis

'Declaración
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

Parámetros

  • content
    Tipo: System.String
    Contenido del archivo de plantilla de texto que se va a procesar.

Valor devuelto

Tipo: System.AppDomain
AppDomain que compila y ejecuta la clase de transformación generada.

Comentarios

El host puede utilizar el parámetro content para proporcionar un AppDomain concreto dependiendo del archivo de plantilla de texto que se va a procesar.Por ejemplo, el host podría almacenar en memoria caché AppDomain si repetidamente se procesa el mismo archivo de plantilla de texto.El host puede omitir el parámetro content si el host no necesita la información.

Ejemplos

El ejemplo de código siguiente muestra una posible implementación para un host personalizado.Este ejemplo de código forma parte de un ejemplo más extenso.Para obtener el ejemplo completo, vea Tutorial: Crear un host de plantillas de texto personalizadas.

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

Seguridad de .NET Framework

Vea también

Referencia

ITextTemplatingEngineHost Interfaz

Microsoft.VisualStudio.TextTemplating (Espacio de nombres)

AppDomain

Otros recursos

Tutorial: Crear un host de plantillas de texto personalizadas