Condividi tramite


Metodo ITextTemplatingEngineHost.ProvideTemplatingAppDomain

Fornisce un dominio applicazione per eseguire la classe della trasformazione generata.

Spazio dei nomi:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (in Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)

Sintassi

'Dichiarazione
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

Parametri

  • content
    Tipo: System.String
    Il contenuto del file modello di testo da elaborare.

Valore restituito

Tipo: System.AppDomain
AppDomain che compila ed esegue la classe della trasformazione generata.

Note

l'host può utilizzare content parametro per fornire uno specifico AppDomain a seconda del file modello di testo da elaborare.Ad esempio, l'host può memorizzare nella cache AppDomain se lo stesso file modello di testo viene elaborato ripetutamente.L'host può ignorare content parametro se l'host non disponga delle informazioni.

Esempi

Nell'esempio di codice seguente viene illustrata un'implementazione anche un host personalizzato.Questo esempio di codice fa parte di un esempio più esaustivo.per l'esempio completo, vedere Procedura dettagliata: creazione di un host del modello di testo personalizzato.

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

ITextTemplatingEngineHost Interfaccia

Spazio dei nomi Microsoft.VisualStudio.TextTemplating

AppDomain

Altre risorse

Procedura dettagliata: creazione di un host del modello di testo personalizzato