Question

What is the difference between IEditableObject and IRevertibleChangeTracking (both from the System.ComponentModel namespace)? It looks as if the first supports explicit transaction whilst the second is more implicit - but the net result is the same. How should I go about implementing this in code? At the moment I do nothing in BeginEdit and call RejectChanges and AcceptChanges in EndEdit and CancelEdit respectively. My problem is that this will also accept the changes made prior to the BeginEdit.

Is that really what Microsoft wanted or am I trying to implement two mutually exclusive interfaces?

Was it helpful?

Solution

The two interfaces are not mutually exclusive. They are simply intended to support different yet somewhat related scenarios, which might as well be implemented by the same given class. Here's a quick explanation:

IEditableObject Interface

The IEditableObject interface is designed to support the scenario where an object needs to manage its internal state in some particular way while it is being edited.

For that reason the interface includes methods that explicitly mark when the editing phase is started, completed or aborted, so that the appropriate actions can be taken to modify the object's state at those stages.


IRevertibleChangeTracking interface

The IRevertibleChangeTracking interface is designed to support the scenario where an object needs to be able to rollback to its previous state.

The interface has methods that mark when the object's current state should be made permanent or it should be reverted to the last known permanent state.

OTHER TIPS

IEditableObject is used for short term, revertanble modifications such as dialog boxes.

IRevertibleChangeTracking is used for long-term, revertible changes such as editing a record and tracking whether or not the record needs to be saved.

I often implement both interfaces so that I have the ability to support two levels of undo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top