Hi,
Question: Is there a way to dynamically add properties to a class at runtime
Background: I'm trying to write an app that lets a user write some code in a text editor at runtime, and then compile and run the code. Compiling and running the code is no problem using the CodeDOM classes, but there's somethign else I'm trying to achieve.
I'm using an editor that provides code completion (CSharpEditor, though I might end up using VSTA) and what I'm looking to do is dynamically add properties to a class. For example, a line of code (at runtime) might be:
Dim Bob as new DataObject(someParam)
If I then type
Bob DOT
then I see a code completion window with each of the properties of the DataObject (name, email, address etc.) However, I also have a set of "DataTypes" that can apply to a DataObject ("Guarantor", "Trustee", "Owner" for example). Getting the list of DataTypes applicable to the DataObject is no problem, but what I would really like to do is "append" each applicable DataType to the DataObject.
For example, therefore, in the constructor of the DataObject, I can go off and find all applicable DataTypes. I can iterate through them. I can even create a new class using the CodeDOM which has properties of for each DataType. However, what I really want to do is so that if they typed
Bob DOT
they'd see a code completion window with all the standard properties, but also the DataTypes... so I guess I'm somehow looking to "merge" two classes, or append the DataTypes class or....
Is this possible (without a hideous amount of reflection)
Cheers.

Runtime compilation / CodeDOM
Johan Cyprich
AVVIT
A different way to say substantially the same think! :)
I'm going to attach to this thread hoping for a good news for us both.