-
-
Notifications
You must be signed in to change notification settings - Fork 39
/
ObjectDumper.cs
34 lines (31 loc) · 1.1 KB
/
ObjectDumper.cs
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
namespace System.Diagnostics
{
public static class ObjectDumper
{
/// <summary>
/// Serializes the given <see cref="element"/> to string of style <see cref="dumpStyle"/>.
/// </summary>
public static string Dump(object element, DumpStyle dumpStyle)
{
return Dump(element, new DumpOptions { DumpStyle = dumpStyle });
}
/// <summary>
/// Serializes the given <see cref="element"/> to string with additional options <see cref="dumpOptions"/>.
/// </summary>
/// <param name="element"></param>
/// <param name="dumpOptions"></param>
/// <returns></returns>
public static string Dump(object element, DumpOptions dumpOptions = default(DumpOptions))
{
if (dumpOptions == default(DumpOptions))
{
dumpOptions = new DumpOptions();
}
if (dumpOptions.DumpStyle == DumpStyle.Console)
{
return ObjectDumperConsole.Dump(element);
}
return ObjectDumperCSharp.Dump(element);
}
}
}