We need to implement some general-purpose object structure, much like an object in dynamic languages, that would give us a possibility of creating the whole object graph on-the-fly. This class has to be serializable and somehow user friendly.
So far we have made some experiments with class derived from Dictionary<string, object> using the dot notation path to store properties and collections in the object tree. We have also find an article that implements something similar, but it doesn’t seem to fit completely into our picture either.
Do you know about some good implementations / libraries that deal with a similar problem or do you have any (non-trivial) ideas that could help us with our own implementation ?
Also, I probably have to say that we are using .NET 3.5, so we can’t take advantage of the new features in .NET 4.0 like dynamic type etc. (as far as I know it’s also not possible to use any subset of it in .NET 3.5 solution).
I’ve done property-bag implementations in the past, including all the muck like
ICustomTypeDescriptor/ITypedListto get it binding – and it can be a lot of work. Especially if you include serialization (not includingBinaryFormatter, which has its own issues).This type of dynamic object doesn’t really fit very well in a generally statically typed language like C#, but it can be made to work. While I’m not their greatest fan (not even a little), could you perhaps just use
DataTable/DataRowhere? It does what you ask, without the many man-hours development / debugging.