I need to execute functionality whereby if the user is going to close the window (or perform some other action) without saving their changes, they are going to be informed with a message box.
In order to be able to do this, I need to be able to know whether changes have been made to the object in question since the window was opened.
I’m thinking a way to do this is to create a copy of the object when the window loads and keep it as _original and then before the window closes I can compare it against the object that may or may not have been changed.
What is the best way to copy the object into _original, without both of them simply having a reference to the same place in memory?
Also, what is the best way to compare the two objects after, to see if the object is different than _original?
You could implement your object in a way where it maintains a
modifiedstate e.g.This would need some extra work like determining when your just initializing the object (unless you restrict it to the constructor only), however, you get the idea.