Exemplo n.º 1
0
        // ------------------------------------------------------------------------
        // dumpTree

        private void DumpTree(StreamWriter output, TreeNode node, int indent,
                              DumpConfiguration dumpConfiguration)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < indent; i++)
            {
                sb.Append(dumpConfiguration.Indent);
            }

            if (dumpConfiguration.IncludeObjectToString)
            {
                sb.Append("[")
                .Append(node.GetType().Name)
                .Append("@")
                .Append(node.GetHashCode().ToString("X"))
                .Append("]");
            }

            sb.Append(StringUtililities.Quote(node?.ToString()));

            if (dumpConfiguration.IncludeNodeSize)
            {
                sb.Append(" (size: ")
                .Append(NodeWidth(node))
                .Append("x")
                .Append(NodeHeight(node))
                .Append(")");
            }

            output.WriteLine(sb);

            foreach (TreeNode n in Tree.Children(node))
            {
                DumpTree(output, n, indent + 1, dumpConfiguration);
            }
        }
Exemplo n.º 2
0
 /**
  * Prints a dump of the tree to the given printStream, using the node's
  * "toString" method.
  *
  * @param printStream &nbsp;
  * @param dumpConfiguration
  *            [default: new DumpConfiguration()]
  */
 public void DumpTree(StreamWriter printStream, DumpConfiguration dumpConfiguration)
 => DumpTree(printStream, Tree.Root, 0, dumpConfiguration);