- Creating C# Expando classes for use in C#
- Something Else
If it is something else, email me: email@example.com and I will see if I can shed any light.
If however it is choice 1, I know how to do this, but it can be quite a big subject. In IE it is really simple to do, you can simply use an attribute on a class and there you have an expando. Basically an expando is an arbitary object that is attached created at runtime on another. If you want you can also use setAttribute on the object and add a variable that way.
this.Test = 1;
currKin .Test = 2;
currKin .Bleep = "bleeeep";
The Object currKin, will have two properties, one test, the other Bleep. It is that simple.
HTMLTable t = new HTMLTable();
The above code would create a HTMLTable with an attribute called readyToDelete with the value false.
Going back to the begining; if it was option 2, I am not too sure how you would achieve dynamic addition of properties or variables to an object, but I assume it would involve Reflection and a lot of extra leg work. I know that there is also such a thing as an ExtenderProvider, but again I am not too sure how it works [Tooltips in Winforms extend the Class that it is attached too by providing an new Propery called "ToolTip"].
I have also heard that C# 3.0 may provide this type of functionality but that is just hearsay, I haven't actually read the spec.
I will look up the Reflection methods; the ExtenderProvider and also C# 3.0 spec.
|My Related Documents|