Share via


RequiresProvidesDirectiveProcessor.GeneratePreInitializationCode Method

When overridden in a derived class, adds code to the initialization code of the generated transformation class. This code is added before the base class is initialized.

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

Syntax

'Declaration
Protected MustOverride Sub GeneratePreInitializationCode ( _
    directiveName As String, _
    codeBuffer As StringBuilder, _
    languageProvider As CodeDomProvider, _
    requiresArguments As IDictionary(Of String, String), _
    providesArguments As IDictionary(Of String, String) _
)
protected abstract void GeneratePreInitializationCode(
    string directiveName,
    StringBuilder codeBuffer,
    CodeDomProvider languageProvider,
    IDictionary<string, string> requiresArguments,
    IDictionary<string, string> providesArguments
)
protected:
virtual void GeneratePreInitializationCode(
    String^ directiveName, 
    StringBuilder^ codeBuffer, 
    CodeDomProvider^ languageProvider, 
    IDictionary<String^, String^>^ requiresArguments, 
    IDictionary<String^, String^>^ providesArguments
) abstract
abstract GeneratePreInitializationCode : 
        directiveName:string * 
        codeBuffer:StringBuilder * 
        languageProvider:CodeDomProvider * 
        requiresArguments:IDictionary<string, string> * 
        providesArguments:IDictionary<string, string> -> unit
protected abstract function GeneratePreInitializationCode(
    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 all directive processors must run before the base class is initialized during a processing run. Any code that this directive processor must run for this directive before the base class is initialized should be concatenated to this buffer.

Remarks

Because GenerateTransformCode can add methods to the generated transformation class, initialization code is often required to call those methods.

This method is called once for each directive that this processor processes. Therefore, you can append the code for each directive to codeBuffer. GetPreInitializationCodeForProcessingRun returns the contents of codeBuffer after all the directives have been processed.

This method is called by ProcessDirective.

Examples

This example generates code that is run before the base class is initialized. This example is part of a larger example for the RequiresProvidesDirectiveProcessor class.

protected override void GeneratePreInitializationCode(string directiveName, StringBuilder codeBuffer, System.CodeDom.Compiler.CodeDomProvider languageProvider, IDictionary<string, string> requiresArguments, IDictionary<string, string> providesArguments)
{
if (StringComparer.InvariantCultureIgnoreCase.Compare(directiveName, DomDirectiveTag) == 0)
{
// Add your code for the pre-initialize stage for this processor.
}
}

.NET Framework Security

See Also

Reference

RequiresProvidesDirectiveProcessor Class

Microsoft.VisualStudio.TextTemplating Namespace

GeneratePostInitializationCode

GenerateTransformCode

ProcessDirective

GetPreInitializationCodeForProcessingRun