/// <summary> /// Visits a single node. /// </summary> /// <param name="node">The node being visited.</param> /// <remarks>This method is in charge of pursuing the visit with the children and references of the given node, as well as raising the <see cref="Visiting"/> event.</remarks> protected virtual void VisitNode([NotNull] IGraphNode node) { if (node == null) { throw new ArgumentNullException(nameof(node)); } visitedNodes.Add(node); if (node != RootNode || !SkipRootNode) { Visiting?.Invoke(node, CurrentPath); } var objectNode = node as IObjectNode; if (objectNode != null) { VisitChildren(objectNode); VisitItemTargets(objectNode); } var memberNode = node as IMemberNode; if (memberNode != null) { VisitMemberTarget(memberNode); } visitedNodes.Remove(node); }
/// <summary> /// Visits a single node. /// </summary> /// <param name="node">The node being visited.</param> /// <param name="currentPath">The path of the node being visited.</param> /// <remarks>This method is in charge of pursuing the visit with the children and references of the given node, as well as raising the <see cref="Visiting"/> event.</remarks> protected virtual void VisitNode(IGraphNode node, GraphNodePath currentPath) { visitedNodes.Add(node); if (node != RootNode || !SkipRootNode) { Visiting?.Invoke(node, currentPath); } VisitChildren(node, currentPath); VisitSingleTarget(node, currentPath); VisitEnumerableTargets(node, currentPath); visitedNodes.Remove(node); }