Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DebugExtensions.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Text;
5 
6 namespace SiliconStudio.Quantum
7 {
8  public static class DebugExtensions
9  {
10  public static string PrintHierarchy(this IModelNode node)
11  {
12  var builder = new StringBuilder();
13  PrintHierarchyInternal(node, 0, builder);
14  return builder.ToString();
15  }
16 
17  private static void PrintHierarchyInternal(IModelNode node, int indentation, StringBuilder builder)
18  {
19  PrintIndentation(indentation, builder);
20  builder.Append(node.Guid + " ");
21  PrintIndentation(indentation, builder);
22  builder.Append(node.Name ?? "<untitled>");
23  builder.Append(": [");
24  builder.Append(node.Content.GetType().Name);
25  builder.Append("] = ");
26  if (node.Content.IsReference)
27  {
28  if (node.Content.Value != null)
29  {
30  builder.Append(node.Content.Value.ToString().Replace(Environment.NewLine, " "));
31  builder.Append(" > ");
32  }
33  builder.Append("Reference -> ");
34  builder.Append(node.Content.Reference);
35  }
36  else if (node.Content.Value == null)
37  {
38  builder.Append("(null)");
39  }
40  else
41  {
42  builder.Append(node.Content.Value.ToString().Replace(Environment.NewLine, " "));
43  }
44  builder.AppendLine();
45  foreach (var child in node.Children)
46  {
47  PrintHierarchyInternal(child, indentation + 4, builder);
48  }
49  }
50 
51  private static void PrintIndentation(int indendation, StringBuilder builder)
52  {
53  for (int i = 0; i < indendation; ++i)
54  builder.Append(' ');
55  }
56  }
57 }
static string PrintHierarchy(this IModelNode node)
The IModelNode interface represents a node in a model object. A model object is represented by a grap...
Definition: IModelNode.cs:16