Opentribe.Memento
0.1.8
See the version list below for details.
dotnet add package Opentribe.Memento --version 0.1.8
NuGet\Install-Package Opentribe.Memento -Version 0.1.8
<PackageReference Include="Opentribe.Memento" Version="0.1.8" />
paket add Opentribe.Memento --version 0.1.8
#r "nuget: Opentribe.Memento, 0.1.8"
// Install Opentribe.Memento as a Cake Addin #addin nuget:?package=Opentribe.Memento&version=0.1.8 // Install Opentribe.Memento as a Cake Tool #tool nuget:?package=Opentribe.Memento&version=0.1.8
// Initialize the Memento // First step is to initialize a Memento object. This object is the “Caretaker” in the memento design pattern. public static Memento.Memento Caretaker { get; set; } = new Memento.Memento();
//Remember and change one attribute //To remember the state of an object, you have to ask the Caretaker to remember each attributes of the object than you are free to modify these attributes.
Caretaker.Remember<MyObject, string>(AnObject, “MyStringAttribute”); // remember
AnObject.MyStringAttribute = “A new state”; // change attribute
Caretaker.Undo(); // restore the previous value
// Remember and change several attributes // To remember the state of an object, you have to ask the Caretaker to remember each attributes of the object than you are free to modify these attributes.
Caretaker.Begin(); // start to remember Caretaker.Remember<MyObject, string>(AnObject, “MyStringAttribute”); // remember first attribute Caretaker.Remember<MyObject, int>(AnObject, “MyIntAttribute”); // remember second attribute Caretaker.End(); // stop registering
AnObject.MyStringAttribute = “A new state”; // change first attribute AnObject.MyIntAttribute = 123; // change second attribute
Caretaker.Undo(); // restores second and first attribute.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
This package has 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.
First release.