Bagikan melalui


DirectiveProcessor.Initialize Method

When overridden in a derived class, initializes the processor instance.

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

Syntax

'Declaration
Public Overridable Sub Initialize ( _
    host As ITextTemplatingEngineHost _
)
public virtual void Initialize(
    ITextTemplatingEngineHost host
)
public:
virtual void Initialize(
    ITextTemplatingEngineHost^ host
)
abstract Initialize : 
        host:ITextTemplatingEngineHost -> unit 
override Initialize : 
        host:ITextTemplatingEngineHost -> unit 
public function Initialize(
    host : ITextTemplatingEngineHost
)

Parameters

Remarks

Initialize(ITextTemplatingEngineHost, CompilerErrorCollection) is called before StartProcessingRun(CodeDomProvider), and gives the directive processor the opportunity to get information it needs from the host.

You can throw an exception during Initialize(ITextTemplatingEngineHost, CompilerErrorCollection) to stop the processing.

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.

private int directiveCount;

public override void Initialize(ITextTemplatingEngineHost host)
{
    directiveCount = 0;
}
Private directiveCount As Integer

Public Overrides Sub Initialize(ByVal host As ITextTemplatingEngineHost)

    directiveCount = 0
End Sub

.NET Framework Security

See Also

Reference

DirectiveProcessor Class

Microsoft.VisualStudio.TextTemplating Namespace

ITextTemplatingEngineHost

LogErrors

StartProcessingRun(CodeDomProvider)

Initialize(ITextTemplatingEngineHost, CompilerErrorCollection)

Other Resources

Creating Custom Text Template Directive Processors

Walkthrough: Creating a Custom Directive Processor