Share via


DirectiveProcessor.GetPreInitializationCodeForProcessingRun Method

When overridden in a derived class, gets code to add to the beginning of the initialize method of the generated transformation class.

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

Syntax

'Declaration
Public MustOverride Function GetPreInitializationCodeForProcessingRun As String
public abstract string GetPreInitializationCodeForProcessingRun()
public:
virtual String^ GetPreInitializationCodeForProcessingRun() abstract
abstract GetPreInitializationCodeForProcessingRun : unit -> string 
public abstract function GetPreInitializationCodeForProcessingRun() : String

Return Value

Type: System.String
A String that contains the code to add to the generated transformation class.

Remarks

This method adds code to the beginning of the Initialize method of the generated transformation class. The Initialize method of the generated transformation class contains a call to the Initialize method of the base class, and this code is added before that call. For example, the following pseudo-code shows what the Initialize method of the generated transformation class might look like:

Method GeneratedTransformationClassInstance.Initialize()

{

<code added by GetPreInitializationCodeForProcessingRun()>

base.Initialize() *This is a call to TextTransformation.Initialize()

<code added by GetPostInitializationCodeForProcessingRun()>

}

Examples

The following code example shows a possible implementation for a custom directive processor. This code example is part of a larger example provided for the DirectiveProcessor class.

public override string GetPreInitializationCodeForProcessingRun()
{
    //We do not need any pre-initialization, so we will just return "".
    //-----------------------------------------------------------------
    return String.Empty;
}
Public Overrides Function GetPreInitializationCodeForProcessingRun() As String

    'We do not need any pre-initialization, so we will just return "".
    '-----------------------------------------------------------------
    Return String.Empty
End Function

.NET Framework Security

See Also

Reference

DirectiveProcessor Class

Microsoft.VisualStudio.TextTemplating Namespace

GetPostInitializationCodeForProcessingRun

GetPreInitializationCodeForProcessingRun

Other Resources

Creating Custom Text Template Directive Processors

Walkthrough: Creating a Custom Directive Processor