Ejemplo n.º 1
0
        /// <summary>
        /// Extended method for describing the node. It works more efficiently with strings
        /// and allows to describe a tree
        /// </summary>
        /// <param name="builder">Resulting string</param>
        /// <param name="node">Source node</param>
        /// <param name="level">Nesting level</param>
        public override void Describe(StringBuilder builder, Node node, int level)
        {
            if (node == null || builder == null)
            {
                return;
            }

            INodeDescriber describer   = NodeDescriberFactory.GetDescriber();
            Node           firstChild  = ((TwoChildrenNode)node).FirstChild;
            Node           secondChild = ((TwoChildrenNode)node).SecondChild;

            this.AddIntent(builder, level);

            builder.Append($"new TwoChildrenNode(\"{node.Name}\"");
            if (firstChild != null)
            {
                builder.Append(",\n");
                describer.Describe(builder, firstChild, level + 1);
            }

            if (secondChild != null)
            {
                builder.Append(",\n");
                describer.Describe(builder, secondChild, level + 1);
            }

            builder.Append(")");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Extended method for describing the node. It works more efficiently with strings
        /// and allows to describe a tree
        /// </summary>
        /// <param name="builder">Resulting string</param>
        /// <param name="node">Source node</param>
        /// <param name="level">Nesting level</param>
        public override void Describe(StringBuilder builder, Node node, int level)
        {
            if (node == null || builder == null)
            {
                return;
            }

            Node child = ((SingleChildNode)node).Child;

            this.AddIntent(builder, level);

            builder.Append($"new SingleChildNode(\"{node.Name}\"");
            if (child != null)
            {
                builder.Append(",\n");
                NodeDescriberFactory.GetDescriber().Describe(builder, child, level + 1);
            }
            builder.Append(")");
        }