muf
muf copied to clipboard
UndoBatch doesn't allow for cancellation of batch
The documentation says that UndoBatch is designed similarly to TransactionScope, but TransactionScope requires a "ts.Complete()" call to commit, otherwise the change is rolled back. In the current UndoBatch, there's no ability to rollback. Conforming to the TransactionScope pattern, or at least providing some kind of .Rollback() would be very useful.
I worked around it with
bool success = true;
using (new UndoBatch(...)) {
...
}
if (!success) {
var root = UndoService.Current[undoroot];
root.Undo();
}