Share via


DirectiveProcessor.IsDirectiveSupported Method

When overridden in a derived class, determines whether the directive processor supports the specified directive.

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

Syntax

'Declaration
Public MustOverride Function IsDirectiveSupported ( _
    directiveName As String _
) As Boolean
public abstract bool IsDirectiveSupported(
    string directiveName
)
public:
virtual bool IsDirectiveSupported(
    String^ directiveName
) abstract
abstract IsDirectiveSupported : 
        directiveName:string -> bool
public abstract function IsDirectiveSupported(
    directiveName : String
) : boolean

Parameters

Return Value

Type: System.Boolean
true if the directive is supported by the processor; otherwise, false.

Implements

IDirectiveProcessor.IsDirectiveSupported(String)

Remarks

One directive processor can support many different directives.

Currently, calling IsDirectiveSupported does not affect the directive processor's state machine. This means that if you return false from this method, the other methods are still called. Ideally, if a directive is not supported, the state machine should terminate. In the future, the engine may be changed to terminate when this method returns false.

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 bool IsDirectiveSupported(string directiveName)
{
    if (string.Compare(directiveName, "CoolDirective", StringComparison.OrdinalIgnoreCase) == 0)
    {
        return true;
    }
    if (string.Compare(directiveName, "SuperCoolDirective", StringComparison.OrdinalIgnoreCase) == 0)
    {
        return true;
    }
    return false;
}
Public Overrides Function IsDirectiveSupported(ByVal directiveName As String) As Boolean

    If String.Compare(directiveName, "CoolDirective", StringComparison.OrdinalIgnoreCase) = 0 Then
        Return True
    End If

    If String.Compare(directiveName, "SuperCoolDirective", StringComparison.OrdinalIgnoreCase) = 0 Then
        Return True
    End If

    Return False
End Function

.NET Framework Security

See Also

Reference

DirectiveProcessor Class

Microsoft.VisualStudio.TextTemplating Namespace

ProcessDirective

Other Resources

Creating Custom T4 Text Template Directive Processors

Walkthrough: Creating a Custom Directive Processor