Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sealed class Dumper
- {
- static public string Dump(Node root)
- {
- StringBuilder builder = new StringBuilder();
- builder.AppendLine(root.Text);
- DumpChildren(builder, "", root);
- return builder.ToString();
- }
- static private void DumpChildren(StringBuilder builder, string prefix, Node node)
- {
- for (int i=0; i != node.Children.Count; ++i)
- {
- Node child = node.Children[i];
- bool isLast = i == node.Children.Count - 1;
- string nodePrefix = prefix + (isLast ? "└─" : "├─");
- string childPrefix = prefix + (isLast ? " " : "│ ");
- builder.AppendLine(nodePrefix + child.Text);
- DumpChildren(builder, childPrefix, child);
- }
- }
- }
Add Comment
Please, Sign In to add comment