Partager via


ITextTemplatingEngineHost.ProvideTemplatingAppDomain, méthode

Fournit un domaine d'application pour exécuter la classe de transformation générée.

Espace de noms :  Microsoft.VisualStudio.TextTemplating
Assembly :  Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (dans Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)

Syntaxe

'Déclaration
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

Paramètres

  • content
    Type : System.String
    Contenu du fichier de modèle de texte à traiter.

Valeur de retour

Type : System.AppDomain
AppDomain qui compile et exécute la classe de transformation générée.

Notes

L'hôte peut utiliser le paramètre content pour fournir un AppDomain spécifique selon le fichier de modèle de texte à traiter.Par exemple, l'hôte peut mettre en cache un AppDomain si le même fichier de modèle de texte est traité à plusieurs reprises.L'hôte peut ignorer le paramètre content si l'hôte n'a pas besoin des informations.

Exemples

L'exemple de code suivant montre une implémentation possible pour un hôte personnalisé.Cet exemple de code est extrait d'un exemple plus développé.Pour obtenir un exemple complet, consultez Procédure pas à pas : création d'un hôte de modèle de texte personnalisé.

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

Sécurité .NET Framework

Voir aussi

Référence

ITextTemplatingEngineHost Interface

Microsoft.VisualStudio.TextTemplating, espace de noms

AppDomain

Autres ressources

Procédure pas à pas : création d'un hôte de modèle de texte personnalisé