I want to add an attribute to property of a dynamic object/expando object runtime, is it possible?
What I would like to do is:
dynamic myExpando = new ExpandoObject();
myExpando.SomeProp = "string";
myExpando.AddAttribute("SomeProp", new MyAttribute());
Is it possible to do that in one way or another?
You can add an attribute to a dynamic object like this:
To read the attributes you should use this:
I am not sure you can read custom attributes like that. However you can also try reflection:
However, with reflection you cannot see the attribute that you have been added because attributes are static metadata.
TypeDescriptor is a metadata engine provided by the .NET FCL. You can read the article here:
http://blogs.msdn.com/b/parthopdas/archive/2006/01/03/509103.aspx