Partilhar via


Método RequiresProvidesDirectiveProcessor.GenerateTransformCode

Quando substituído em uma classe derivada, adiciona código para a classe de transformação gerada.

Namespace:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating.10.0 (em Microsoft.VisualStudio.TextTemplating.10.0.dll)

Sintaxe

'Declaração
Protected MustOverride Sub GenerateTransformCode ( _
    directiveName As String, _
    codeBuffer As StringBuilder, _
    languageProvider As CodeDomProvider, _
    requiresArguments As IDictionary(Of String, String), _
    providesArguments As IDictionary(Of String, String) _
)
protected abstract void GenerateTransformCode(
    string directiveName,
    StringBuilder codeBuffer,
    CodeDomProvider languageProvider,
    IDictionary<string, string> requiresArguments,
    IDictionary<string, string> providesArguments
)
protected:
virtual void GenerateTransformCode(
    String^ directiveName, 
    StringBuilder^ codeBuffer, 
    CodeDomProvider^ languageProvider, 
    IDictionary<String^, String^>^ requiresArguments, 
    IDictionary<String^, String^>^ providesArguments
) abstract
abstract GenerateTransformCode : 
        directiveName:string * 
        codeBuffer:StringBuilder * 
        languageProvider:CodeDomProvider * 
        requiresArguments:IDictionary<string, string> * 
        providesArguments:IDictionary<string, string> -> unit 
protected abstract function GenerateTransformCode(
    directiveName : String, 
    codeBuffer : StringBuilder, 
    languageProvider : CodeDomProvider, 
    requiresArguments : IDictionary<String, String>, 
    providesArguments : IDictionary<String, String>
)

Parâmetros

  • codeBuffer
    Tipo: System.Text.StringBuilder
    O buffer concatena o código que o processador de diretriz adiciona à classe de transformação gerado durante o processamento de execução.

Comentários

Isso é chamado por ProcessDirective.

Exemplos

Este exemplo gera código para o processador de diretriz. Este código de exemplo é parte de um exemplo maior fornecido para a classe RequiresProvidesDirectiveProcessor.

protected override void GenerateTransformCode(string directiveName, StringBuilder codeBuffer, System.CodeDom.Compiler.CodeDomProvider languageProvider, IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments)
{
// Write code to create a property backed by a field of type XmlDocument.
// The property is named "Dom" by default but the template writer may have changed the name using a custom provides clause like 'provides="Dom=AnotherName"'
string fieldName = providesArguments[DomProvidedParameterName].ToLower(CultureInfo.InvariantCulture) + "Value";
string propertyName = providesArguments[DomProvidedParameterName];
codeBuffer.Append(
"XmlDocument " + fieldName + ";" +
"XmlDocument " + propertyName +
"{ get { return this." + fieldName + "; } }");
}

Segurança do .NET Framework

Consulte também

Referência

RequiresProvidesDirectiveProcessor Classe

Namespace Microsoft.VisualStudio.TextTemplating

GeneratePreInitializationCode

GeneratePostInitializationCode

ProcessDirective