DirectiveProcessor.GetImportsForProcessingRun Method

When overridden in a derived class, gets namespaces to import into the generated transformation class.

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

Syntax

'Declaration
Public MustOverride Function GetImportsForProcessingRun As String()
public abstract string[] GetImportsForProcessingRun()
public:
virtual array<String^>^ GetImportsForProcessingRun() abstract
abstract GetImportsForProcessingRun : unit -> string[] 
public abstract function GetImportsForProcessingRun() : String[]

Return Value

Type: array<String[]
An array of type String that contains the namespaces.

Implements

IDirectiveProcessor.GetImportsForProcessingRun()

Remarks

If the directive processor wants its own code to be conveniently accessible to the generated transformation class, the directive processor should add its own namespace to the list of namespaces.

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[] GetImportsForProcessingRun()
{
    //This returns the imports or using statements that we want to 
    //add to the generated transformation class.
    //-----------------------------------------------------------------
    //We need CustomDP to be able to call XmlReaderHelper.ReadXml
    //from the generated transformation class.
    //-----------------------------------------------------------------
    return new string[]
    {
        "System.Xml",
        "CustomDP"
    };
}
Public Overrides Function GetImportsForProcessingRun() As String()

    'This returns the imports or using statements that we want to 
    'add to the generated transformation class.
    '-----------------------------------------------------------------
    'We need CustomDP to be able to call XmlReaderHelper.ReadXml
    'from the generated transformation class.
    '-----------------------------------------------------------------
    Return New String() {"System.Xml", "CustomDP"}
End Function

.NET Framework Security

See Also

Reference

DirectiveProcessor Class

Microsoft.VisualStudio.TextTemplating Namespace

GetReferencesForProcessingRun

GetClassCodeForProcessingRun

GetImportsForProcessingRun

Other Resources

Creating Custom T4 Text Template Directive Processors

Walkthrough: Creating a Custom Directive Processor