Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • 2 weeks later...
Posted

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.

Posted
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.

Posted
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).

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...