4 using System.Diagnostics.Contracts;
8 namespace SiliconStudio.Presentation.Quantum
14 foreach (var child
in node.Children)
16 if (child.Parent != node)
17 throw new Exception(
"Parent/Children mismatch");
18 AssertHierarchy(child);
25 var builder =
new StringBuilder();
26 PrintHierarchyInternal(node, 0, builder);
27 return builder.ToString();
30 private static void PrintHierarchyInternal(
IObservableNode node,
int indentation, StringBuilder builder)
32 PrintIndentation(indentation, builder);
33 builder.Append(node.Name ??
"<untitled>");
34 if (node.
Index != null)
37 builder.Append(node.Index);
40 builder.Append(
": [");
41 builder.Append(node.Type.Name);
42 builder.Append(
"] = ");
43 builder.Append(node.Value == null ?
"(null)" : node.Value.ToString().Replace(Environment.NewLine,
" "));
47 builder.Append(
"Cmd: ");
48 foreach (var command
in node.
Commands)
51 builder.Append(((NodeCommandWrapperBase)command).Name);
58 PrintHierarchyInternal(child, indentation + 4, builder);
62 private static void PrintIndentation(
int indendation, StringBuilder builder)
64 for (
int i = 0; i < indendation; ++i)
IReadOnlyCollection< IObservableNode > Children
Gets the list of children nodes.
object Index
Gets or sets the index of this node, relative to its parent node when its contains a collection...
static void AssertHierarchy(this IObservableNode node)
IEnumerable< INodeCommandWrapper > Commands
Gets the list of commands available in this node.
static string PrintHierarchy(this IObservableNode node, int indentation=0)