View difference between Paste ID: K7VQYxhq and
SHOW: | | - or go back to the newest paste.
1-
1+
sealed class Dumper
2
{
3
    static public string Dump(Node root) 
4
    {
5
        return root.Text + "\n" + DumpChildren( root, "" );
6
    }
7
    static private string DumpChildren(Node node, string indent)
8
    {
9
        return node.Children.Count == 0
10
            ? "" : node.Children.Take(node.Children.Count - 1).
11
                        Aggregate(string.Empty, (results, child) => 
12
                            results + indent + "├─" + child.Text + "\n" + DumpChildren(child, indent + "│ ") )
13
                    + indent + "└─" + node.Children.Last().Text + "\n" + DumpChildren(node.Children.Last(), indent + "  " );
14
    }
15
}