-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathDebugTools.cs
More file actions
51 lines (45 loc) · 1.4 KB
/
DebugTools.cs
File metadata and controls
51 lines (45 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
namespace kOS
{
public static class DebugTools
{
public static string DisplayObjectInfo(Object o)
{
StringBuilder sb = new StringBuilder();
// Include the type of the object
System.Type type = o.GetType();
sb.Append("Type: " + type.Name);
// Include information for each Field
sb.Append("\r\n\r\nFields:");
System.Reflection.FieldInfo[] fi = type.GetFields();
if (fi.Length > 0)
{
foreach (FieldInfo f in fi)
{
sb.Append("\r\n " + f.ToString() + " = " +
f.GetValue(o));
}
}
else
sb.Append("\r\n None");
// Include information for each Property
sb.Append("\r\n\r\nProperties:");
System.Reflection.PropertyInfo[] pi = type.GetProperties();
if (pi.Length > 0)
{
foreach (PropertyInfo p in pi)
{
sb.Append("\r\n " + p.ToString() + " = " +
p.GetValue(o, null));
}
}
else
sb.Append("\r\n None");
return sb.ToString();
}
}
}