An object has some properties , now at runtime — when a condition is met .. I want to add new properties to this object .
“DynamicObject” cant be ustilised since i wont be knowing the property Names beforehand .
I came acroos PropertyBuilder http://msdn.microsoft.com/en-us/library/system.reflection.emit.propertybuilder.aspx
But i cant find help regarding how to use the propertBuilder for adding properties to an existing object of a defined-existing class.
You cannot add real (reflection) properties to an object or type at runtime.
If the context here is data-binding, then you can all artificial properties, by implementing one or more of
ICustomTypeDescriptor,TypeDescriptionProvider,TypeConverter,ITypedList– and providing your ownPropertyDescriptors for the extra properties.ICustomTypeDescriptoris per-object and tied to that objectTypeDescriptionProvideris per-object or per-type, and is separate to the objectTypeConverteris per-type and is used in particular byPropertyGridITypedListis used by a list (IList) to describe the properties of the child objectsExample: