UndoService 2.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package UndoService --version 2.0.2                
NuGet\Install-Package UndoService -Version 2.0.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UndoService" Version="2.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UndoService --version 2.0.2                
#r "nuget: UndoService, 2.0.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install UndoService as a Cake Addin
#addin nuget:?package=UndoService&version=2.0.2

// Install UndoService as a Cake Tool
#tool nuget:?package=UndoService&version=2.0.2                

UndoService

Simple undo/redo service based on the momento pattern. It uses delegates to access state. It can track changes to different parts of the application individually, while using one unified interface for performing undo/redo. This reduces the memory imprint and facilitates modular design. See the unit tests for examples of usage. https://github.com/peterdongan/UndoService

The simplest approach is to use a single UndoService for application state. Alternatively you can use separate UndoServices for different sections in conjunction with an AggregatedUndoService. This means that the whole of the application state does not need to be recorded on each change.

UndoService Class

This can be used by itself to record state and perform undo/redo actions, or it can be used as a subservice of AggregateUndoService to manage changes to a particular segment. In the latter case, Undo() and Redo() should only be invoked via the AggregateUndoService. View the unit tests for example of both forms of use.

UndoService Constructor

Set the type that is used to record the state. Pass the delegate methods that are used to get and set the state. (If necessary use a wrapper to match the expected signature.) Optionally set a cap on the number of states stored.

UndoService(GetState<T> getState, SetState<T> setState, int? cap)	

If there is no cap then stacks are used for the undo and the redo stack. If there is a cap then a dropout stack is used for the undo stack.

UndoService Properties

Check CanUndo and CanRedo properties before invoking Undo() or Redo() respectively.

bool CanUndo
bool CanRedo

UndoService Methods

Invoke RecordState() to add the current state to the undo history.

void RecordState() 
void Undo()
void Redo()
void ClearStacks()
void ClearUndoStacks()

AggregateUndoService Class

This can be used with multiple UndoServices to manage Undo/Redo across separate segments of the application. In this case, the child UndoServices look after change tracking and Undo/Redo is done via the AggregateUndoService. Most of the members are similar to UndoService so they are not duplicated here.

AggregateUndoService Constructor

Pass an array of the UndoServices that are used for different parts of the application.

AggregateUndoService(IUndoService[] subUndoServices)

LICENCE

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.3.2 1,821 11/17/2020
2.3.1 481 7/22/2020
2.3.1-alpha 345 7/21/2020
2.3.0-alpha 348 7/21/2020
2.2.3-alpha 320 7/15/2020
2.2.2-alpha 346 6/22/2020
2.2.0-alpha 349 6/3/2020
2.1.11 485 6/2/2020
2.1.11-alpha 346 5/28/2020
2.1.10-alpha 366 5/28/2020
2.1.9-alpha 312 5/28/2020
2.1.8-alpha 364 5/28/2020
2.1.7-alpha 368 5/27/2020
2.1.6-alpha 316 5/26/2020
2.1.5-alpha 298 5/26/2020
2.1.4-alpha 326 5/26/2020
2.1.3-alpha 353 5/25/2020
2.1.2-alpha 366 5/25/2020
2.0.2 486 5/21/2020
1.1.0 496 3/27/2020
1.0.0 512 3/16/2020

2.0.2 Fixed bug using Undo after Redo in an AggregateUndoService.
2.0.1 Fixed bug recording state in an individual (standalone) UndoService.
2.0.0 AggregateUndoService added.