Undo/Redo functionality in .NET

You need to implement Undo/Redo functionality? Seems I have something to show you… I think, that everyone, who needs to implement Undo/Redo functionality in an .NET project should take a look at the great DejaVu library.

In short, all that you need is just wrap the fields by UndoRedo Generic class. And after that you’ll be able to use DejaVu’s transaction mechanizm

//Field declaration class MyData { private readonly UndoRedo name = new UndoRedo("");

public string string Name
    get { return name.Value; }
    set { name.Value = value; }
} //... }

// Usage exampe. // NOTE: Exceptions will be handled correctly since in case of exception UndoRedoManager.Cancel() method will be called. using (UndoRedoManager.Start(“My Command”)) { UndoRedoManager.Commit(); } </code>