I'm writing a plug-in for a program where I need to track when native objects are added, removed, and edited in the active document. The API has events that are fired when the document is edited. However, the program does not track when the native objects actually change. Instead an object changing is treated as the object being deleted and then immediately replaced with another modified object with the same ID. This is done this way so the program can keep track of an undo record.
After some experimenting I've determined that the events are evoked as follows:
An Object Is Added: OnAddObject Event
An Object Is Removed: OnDeleteObject Event
An Object is Changed: OnReplaceObject Event->OnDeleteObject Event->OnAddObject Event
Right now my plug-in is only watching the OnAdd and OnDelete events where it is adding and removing instances of my custom object to and from a collection. But this also means every time an object changes my plugin is removing an reinitializing a near identical object. I'd rather just know that the document object has changed so my custom object can be refreshed rather then completely reinstantiated.
How can my methods that are subscribed to the OnDelete and OnAdd events tell that the object is not really being added or deleted but is being replaced because it has changed?