RequiresProvidesDirectiveProcessor.GenerateTransformCode Method

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

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

Syntax

'宣言
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) _
)
'使用
Dim directiveName As String
Dim codeBuffer As StringBuilder
Dim languageProvider As CodeDomProvider
Dim requiresArguments As IDictionary(Of String, String)
Dim providesArguments As IDictionary(Of String, String)

Me.GenerateTransformCode(directiveName, _
    codeBuffer, languageProvider, requiresArguments, _
    providesArguments)
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
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 + "; } }");
}

Permissions

See Also

Reference

RequiresProvidesDirectiveProcessor Class

RequiresProvidesDirectiveProcessor Members

Microsoft.VisualStudio.TextTemplating Namespace

GeneratePreInitializationCode

GeneratePostInitializationCode

ProcessDirective