NodeVisitor<TContext, TBaseNode, TNode, TResult> Class ​
Definition ​
A Visitor<TContext, TNode, TResult> that only visits nodes of a specific type. Visiting a node of any other type calls VisitUnhandledNode(TContext, TBaseNode), which throws by default. Typed visitors are usually combined in a CompositeVisitor<TContext, TBaseNode, TResult>, which dispatches each node to the visitor for its type.
c#
public abstract class NodeVisitor<TContext, TBaseNode, TNode, TResult> : Visitor<TContext, TBaseNode, TResult>
where TBaseNode : Node<TBaseNode>
where TNode : TBaseNodeType Parameters ​
| Name | Description |
|---|---|
TContext | The type of the context object. |
TBaseNode | The base type of all nodes in the tree. |
TNode | The type of the nodes to visit. |
TResult | The type of the result of visiting a node. |
Constructors ​
| Name | Description |
|---|---|
NodeVisitor() |
Methods ​
| Name | Description |
|---|---|
VisitNode(TContext, TBaseNode) | Called to visit a node. |
VisitNode(TContext, TNode) | Called to visit a node of type TNode. |
VisitUnhandledNode(TContext, TBaseNode) | Called to visit a node that is not of type TNode. Throws an InvalidOperationException by default; override to return a fallback value instead. |