Skip to content

Instantly share code, notes, and snippets.

@0V
Last active December 31, 2018 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0V/a207e98e88ac176d7b3d5562f4741e98 to your computer and use it in GitHub Desktop.
Save 0V/a207e98e88ac176d7b3d5562f4741e98 to your computer and use it in GitHub Desktop.
namespace ObjectDumpTest
{
public class SomeCollections
{
public int[] SomeArray { get; set; } = new[] { 0, 1, 2, 3, 4 };
public List<int> SomeList { get; set; } = new List<int> { 0, 1, 2, 3, 4 };
public Dictionary<string, int> SomeLDictionary { get; set; } = new Dictionary<string, int>() { { "One", 1 }, { "Two", 2 } };
public IEnumerable<int> SomeEnumerable { get { return SomeList; } }
public IEnumerable<int> SomeLazyEnumerable { get { return LazyNumber(); } }
private IEnumerable<int> LazyNumber()
{
for (int i = 0; i < 5; i++)
{
// Some Heavy Process
Thread.Sleep(500);
yield return i;
}
}
}
public class Human
{
public int Age { get; set; }
public string Name { get; set; }
public SomeCollections SomeCollections { get; set; } = new SomeCollections();
}
public class BookElement
{
public Human Human { get; set; }
public DateTime Date { get; set; } = DateTime.Now;
}
class Program
{
static void Main(string[] args)
{
var bookList = new List<BookElement>
{
new BookElement { Human = new Human { Name = "John", Age = 20, } } ,
new BookElement { Human = new Human { Name = "Alice", Age = 10, } } ,
};
var dumpData = ObjectDumper.Dump(bookList);
Console.WriteLine(dumpData);
Console.ReadLine();
}
}
}
{ObjectDumpTest.BookElement}
Human: { }
{ObjectDumpTest.Human}
Age: 20
Name: "John"
SomeCollections: { }
{ObjectDumpTest.SomeCollections}
SomeArray: ...
0
1
2
3
4
SomeList: ...
0
1
2
3
4
SomeLDictionary: ...
[One, 1]
[Two, 2]
SomeEnumerable: ...
0
1
2
3
4
SomeLazyEnumerable: ...
0
1
2
3
4
Date: 2018/12/31 15:36:47
{ObjectDumpTest.BookElement}
Human: { }
{ObjectDumpTest.Human}
Age: 10
Name: "Alice"
SomeCollections: { }
{ObjectDumpTest.SomeCollections}
SomeArray: ...
0
1
2
3
4
SomeList: ...
0
1
2
3
4
SomeLDictionary: ...
[One, 1]
[Two, 2]
SomeEnumerable: ...
0
1
2
3
4
SomeLazyEnumerable: ...
0
1
2
3
4
Date: 2018/12/31 15:36:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment