public DumpNode ( bool recursive ) : string | ||
recursive | bool | Flag is qualifier and child nodes shall be rendered too |
return | string |
//------------------------------------------------------------------------------ private methods /// <summary> /// Dumps this node and its qualifier and children recursively. /// <em>Note:</em> It creats empty options on every node. /// </summary> /// <param name="result"> the buffer to append the dump. </param> /// <param name="recursive"> Flag is qualifier and child nodes shall be rendered too </param> /// <param name="indent"> the current indent level. </param> /// <param name="index"> the index within the parent node (important for arrays) </param> private void DumpNode(StringBuilder result, bool recursive, int indent, int index) { // write indent for (int i = 0; i < indent; i++) { result.Append('\t'); } // render Node if (_parent != null) { if (Options.Qualifier) { result.Append('?'); result.Append(_name); } else if (Parent.Options.Array) { result.Append('['); result.Append(index); result.Append(']'); } else { result.Append(_name); } } else { // applies only to the root node result.Append("ROOT NODE"); if (!String.IsNullOrEmpty(_name)) { // the "about" attribute result.Append(" ("); result.Append(_name); result.Append(')'); } } if (!String.IsNullOrEmpty(_value)) { result.Append(" = \""); result.Append(_value); result.Append('"'); } // render options if at least one is set if (Options.ContainsOneOf(0xffffffff)) { result.Append("\t("); result.Append(Options.ToString()); result.Append(" : "); result.Append(Options.OptionsString); result.Append(')'); } result.Append('\n'); // render qualifier if (recursive && HasQualifier()) { XmpNode[] quals = new XmpNode[Qualifier.Count]; Qualifier.CopyTo(quals, 0); int i = 0; while (quals.Length > i && (XmpConst.XML_LANG.Equals(quals[i].Name) || "rdf:type".Equals(quals[i].Name))) { i++; } Array.Sort(quals, i, quals.Length - i); for (i = 0; i < quals.Length; i++) { XmpNode qualifier = quals[i]; qualifier.DumpNode(result, recursive, indent + 2, i + 1); } } // render children if (recursive && HasChildren()) { XmpNode[] children = new XmpNode[Children.Count]; Children.CopyTo(children, 0); if (!Options.Array) { Array.Sort(children); } for (int i = 0; i < children.Length; i++) { XmpNode child = children[i]; child.DumpNode(result, recursive, indent + 1, i + 1); } } }