In my application, I have a set of data objects that determine what types of data the application collects when it runs.
A user can open a dialog box for editing these objects, and this dialog box contains DataGridView instances bound to collections. This means that any changes made by the user are instantly applied, which is not very good.
Another problem is that there is a Cancel button in this dialog box, which allows the user to discard all changes that they have made since the window was opened.
Currently, when the window is open, I serialize all objects (a shallow copy does not work), and if the user clicks the Cancel button, I will deserialize them to restore them. The problem I am facing is that it is messy. It changes all links, and some of these objects also store a data history that is not serialized. Then I have to have events breaking through the application to notify objects when their links are updated, etc. It is a pain.
Is there a better approach to this problem?
source share