rbulph Posted December 21, 2005 Posted December 21, 2005 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? Quote
Mister E Posted December 30, 2005 Posted December 30, 2005 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. Quote
rbulph Posted December 30, 2005 Author Posted December 30, 2005 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. Quote
Mister E Posted December 30, 2005 Posted December 30, 2005 You could also just use the PropertyBinding features of .NET to save the settings in the application configuration file. Quote
rbulph Posted January 4, 2006 Author Posted January 4, 2006 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). Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.