Delen via


RequiresProvidesDirectiveProcessor.GenerateTransformCode Method

When overridden in a derived class, adds code to the generated transformation class.

Namespace:  Microsoft.VisualStudio.TextTemplating
Assembly:  Microsoft.VisualStudio.TextTemplating.12.0 (in Microsoft.VisualStudio.TextTemplating.12.0.dll)

Syntax

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

Parameters

  • codeBuffer
    Type: System.Text.StringBuilder

    The buffer that concatenates the code that this directive processor adds to the generated transformation class during a processing run.

Remarks

This is called by ProcessDirective.

Examples

This example generates code for the directive processor. This code example is part of a larger example that is provided for the RequiresProvidesDirectiveProcessor class.

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 + "; } }");
}

.NET Framework Security

See Also

Reference

RequiresProvidesDirectiveProcessor Class

Microsoft.VisualStudio.TextTemplating Namespace

GeneratePreInitializationCode

GeneratePostInitializationCode

ProcessDirective