Adding Properties temporarily

rbulph

Junior Contributor
Joined
Feb 17, 2003
Messages
397
Is it possible to add properties to a class temporarily at run time?

I'm saving the locations of some user controls with serialization. The user controls can't be serialized, because controls can't, so I need to store the locations in some related objects which I can serialize. I need the related objects in any case. The related objects only need this data for serialization, and it would be nice if I could just give them the property for storing this information while serialization takes place. Is there any way this can be done?
 
Possible? Yes. Practical. No

To do what you're talking about, just make a simple class that has properties for "ControlName", "PropertyName", "PropertyValue", and perhaps "PropertyDataType". Create another class that holds a collection of the first class. Serialize the second class and store that. Using XML serialization probably makes the most sense for something like this.
 
Mister E said:
Possible? Yes. Practical. No

To do what you're talking about, just make a simple class that has properties for "ControlName", "PropertyName", "PropertyValue", and perhaps "PropertyDataType". Create another class that holds a collection of the first class. Serialize the second class and store that. Using XML serialization probably makes the most sense for something like this.
Thanks, that's what I'd concluded I'd have to do.
 
You could also just use the PropertyBinding features of .NET to save the settings in the application configuration file.
 
Mister E said:
You could also just use the PropertyBinding features of .NET to save the settings in the application configuration file.
No, these properties relate to individual files, not the application (it's a bit of an unusual application).
 
Back
Top