I\'ve noticed that the new ExpandoObject
implements IDictionary
which has the requisite IEnumerable
The opensource framework Dynamitey has an alternative syntax for building ExpandoObject
instances inline.
dynamic obj = Builder.New(
foo:"hello",
bar: 42 ,
baz: new object()
);
int value = obj.bar;
It also has a dictionary based dynamic prototype object Dynamitey.DynamicObjects.Dictionary
such that
dynamic obj = new Dynamitey.DynamicObjects.Dictionary()
{
{ "foo", "hello" },
{ "bar", 42 },
{ "baz", new object() }
};
int value = obj.bar;
works too.