I’m writing a logging framework and need to serialize each object in an IDictionary<string,object>. Object can be a simple string, int etc. or a complex business object or a collection of either. Therefore I need a flexible method for doing this.
At the more complex end of things I’d like the output to be something like:
Object = IList<Person>
- List Of Person:
- Person:
- Name: David Neale
- Gender: Male
- Person:
- Name: John Smith
- Gender: Male
- Person:
I don’t need to handle nested to the level of the object containing a collection which contains collections.
Could somebody point me in the right direction?
Take a look at the answers to this question on SO to get you started.
Basically, there’s no built-in mechanism to do so in .NET – however, you can look at some of the objectDump code that’s out on the web, like this.
FYI: Apparently the ObjectDumper code is something that is part of the VS C# samples (see Eric White’s blog):