Freigeben über


ITextTemplatingEngineHost.ProvideTemplatingAppDomain-Methode

Stellt eine Anwendungsdomäne bereit, um die generierte Transformationsklasse auszuführen.

Namespace:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (in Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)

Syntax

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

Parameter

  • content
    Typ: System.String
    Der Inhalt einer Textvorlagendatei, die verarbeitet werden soll.

Rückgabewert

Typ: System.AppDomain
Eine AppDomain, die die generierte Transformationsklasse kompiliert und ausführt.

Hinweise

Der Host kann abhängig von der zu verarbeitenden Textvorlagendatei mithilfe des content-Parameters eine bestimmte AppDomain zur Verfügung stellen. Der Host kann z. B. eine AppDomain zwischenspeichern, wenn die gleiche Textvorlagendatei immer wieder verarbeitet wird. Der Host kann den content-Parameter ignorieren, wenn der Host die Informationen nicht benötigt.

Beispiele

Im folgenden Codebeispiel wird eine mögliche Implementierung für einen benutzerdefinierten Host veranschaulicht. Dieses Codebeispiel ist Teil eines umfangreicheren Beispiels. Das vollständige Beispiel finden Sie unter Exemplarische Vorgehensweise: Erstellen eines benutzerdefinierten Textvorlagenhosts.

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-Sicherheit

Siehe auch

Referenz

ITextTemplatingEngineHost Schnittstelle

Microsoft.VisualStudio.TextTemplating-Namespace

AppDomain

Weitere Ressourcen

Exemplarische Vorgehensweise: Erstellen eines benutzerdefinierten Textvorlagenhosts