C# Class Memento.Mementor

Provides undo and redo services.
Inheritance: IDisposable
显示文件 Open project: buunguyen/memento Class Usage Examples

Public Methods

Method Description
Batch ( System.Action codeBlock ) : void

Marks a batch during which all events are combined so that Undo only needs calling once.

Batches cannot be nested. At any point, there must be only one active batch.

BeginBatch ( ) : void

Explicitly marks the beginning of a batch. Use this instead of Batch changes can be made in different places instead of inside one certain block of code. When finish, end the batch by invoking EndBatch.

Dispose ( ) : void

Disposes the this mementor and clears redo and undo stacks. This method won't fire Changed event.

EndBatch ( ) : void

Ends a batch.

ExecuteNoTrack ( System.Action codeBlock ) : void

Executes the supplied code block with IsTrackingEnabled turned off.

MarkEvent ( BaseEvent anEvent ) : void

Marks an event. This method also serves as an extensibility point for custom events.

Mementor ( bool isEnabled = true ) : System

Creates an instance of Mementor.

Redo ( ) : void

Performs a redo.

Reset ( ) : void

Resets the state of this Mementor object to its initial state. This effectively clears the redo stack, undo stack and current batch (if one is active).

Undo ( ) : void

Performs an undo.

Private Methods

Method Description
InternalEndBatch ( BatchEvent stack ) : BaseEvent
NotifyChange ( BaseEvent @event ) : void
PerformPostMarkAction ( BaseEvent @event ) : void
ProcessBatch ( BatchEvent batchEvent ) : BaseEvent
RollbackEvent ( BaseEvent @event, bool undoing ) : void

Method Details

Batch() public method

Marks a batch during which all events are combined so that Undo only needs calling once.
Batches cannot be nested. At any point, there must be only one active batch.
public Batch ( System.Action codeBlock ) : void
codeBlock System.Action The code block performing batch change marking.
return void

BeginBatch() public method

Explicitly marks the beginning of a batch. Use this instead of Batch changes can be made in different places instead of inside one certain block of code. When finish, end the batch by invoking EndBatch.
public BeginBatch ( ) : void
return void

Dispose() public method

Disposes the this mementor and clears redo and undo stacks. This method won't fire Changed event.
public Dispose ( ) : void
return void

EndBatch() public method

Ends a batch.
public EndBatch ( ) : void
return void

ExecuteNoTrack() public method

Executes the supplied code block with IsTrackingEnabled turned off.
public ExecuteNoTrack ( System.Action codeBlock ) : void
codeBlock System.Action The code block to be executed.
return void

MarkEvent() public method

Marks an event. This method also serves as an extensibility point for custom events.
public MarkEvent ( BaseEvent anEvent ) : void
anEvent BaseEvent The event to be marked.
return void

Mementor() public method

Creates an instance of Mementor.
public Mementor ( bool isEnabled = true ) : System
isEnabled bool Whether this instance is enabled or not.
return System

Redo() public method

Performs a redo.
public Redo ( ) : void
return void

Reset() public method

Resets the state of this Mementor object to its initial state. This effectively clears the redo stack, undo stack and current batch (if one is active).
public Reset ( ) : void
return void

Undo() public method

Performs an undo.
public Undo ( ) : void
return void