Current situation
I have a WPF application where I use MVVM and NHibernate. I have a master/detail window with a listbox with all my customers, and the selectedItem of the listbox is the object that is being used to display the customerdetails in the detailscreen. In the detailscreen I have an add, edit, delete, save and an undo buttton. Everything works with the binding I've set up.
Problem
But for my undo button I was thinking of making a copy of the original Customer object so when I click the undo button the field will be resetted to the values from the original values. But in my customer object I have an Address object and with a shallow copy the 2 objects will keep the same reference to that object. So when I change a field from the Address object the original Customer address will also be changed. I was thinking of doing a deep copy of my Customer address but I can't make my object serializable (It's not in my control to change the Model objects)
- Is there any way to do a deep copy without serialization?
- Or is there some standard way to accomplish the behavior I want to achieve?