internal override TreeNode Print(DbExpressionVisitor<TreeNode> visitor) { var node = new TreeNode("DbSetClause"); if (null != Property) { node.Children.Add(new TreeNode("Property", Property.Accept(visitor))); } if (null != Value) { node.Children.Add(new TreeNode("Value", Value.Accept(visitor))); } return node; }
/// <summary> /// Called to recursively visit the child nodes of the current TreeNode. /// </summary> /// <param name="text"> The StringBuilder into which the tree is being printed </param> /// <param name="node"> The current node </param> internal virtual void PrintChildren(StringBuilder text, TreeNode node) { _scopes.Add(node); node.Position = 0; foreach (var childNode in node.Children) { text.AppendLine(); node.Position++; PrintNode(text, childNode); } _scopes.RemoveAt(_scopes.Count - 1); }
/// <summary> /// The recursive step of the printing process, called once for each TreeNode in the tree /// </summary> /// <param name="text"> The StringBuilder into which the tree is being printed </param> /// <param name="node"> The current node that should be printed to the StringBuilder </param> internal virtual void PrintNode(StringBuilder text, TreeNode node) { IndentLine(text); BeforeAppend(node, text); text.Append(node.Text); AfterAppend(node, text); PrintChildren(text, node); }
/// <summary> /// Called once for every node immediately after the line prefix (if any) and appropriate /// indentation and connecting lines have been added to the output but before the node's /// text value has been added. /// </summary> /// <param name="node"> The current node </param> /// <param name="text"> The StringBuilder into which the tree is being printed </param> internal virtual void BeforeAppend(TreeNode node, StringBuilder text) { }
/// <summary> /// Called once for every node after indentation, connecting lines and the node's text value /// have been added to the output but before the line suffix (if any) has been added. /// </summary> /// <param name="node"> The current node </param> /// <param name="text"> The StringBuilder into which the tree is being printed </param> internal virtual void AfterAppend(TreeNode node, StringBuilder text) { }
// 'protected' constructor // 'protected' API that may be overriden to customize printing /// <summary> /// Called once on the root of the tree before printing begins /// </summary> /// <param name="node"> The TreeNode that is the root of the tree </param> internal virtual void PreProcess(TreeNode node) { }
/// <summary> /// Entry point method for the TreePrinter /// </summary> /// <param name="node"> The TreeNode instance that is the root of the tree to be printed </param> /// <returns> A string representation of the specified tree </returns> internal virtual string Print(TreeNode node) { PreProcess(node); var text = new StringBuilder(); PrintNode(text, node); return text.ToString(); }