Class MementoAttribute
- Namespace
- PatternKit.Generators
- Assembly
- PatternKit.Generators.Abstractions.dll
Marks a type (class/struct/record class/record struct) for Memento pattern code generation. Generates an immutable memento struct for capturing and restoring state snapshots, with optional undo/redo caretaker history management.
[AttributeUsage(AttributeTargets.Class|AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
public sealed class MementoAttribute : Attribute
- Inheritance
-
MementoAttribute
- Inherited Members
Properties
Capacity
Maximum number of snapshots to retain in the caretaker history. When the limit is exceeded, the oldest snapshot is evicted (FIFO). Default is 0 (unbounded). Only applies when GenerateCaretaker is true.
public int Capacity { get; set; }
Property Value
GenerateCaretaker
When true, generates a caretaker class for undo/redo history management. Default is false (generates only the memento struct).
public bool GenerateCaretaker { get; set; }
Property Value
InclusionMode
Member selection mode for the memento. Default is IncludeAll (all public instance properties/fields with getters).
public MementoInclusionMode InclusionMode { get; set; }
Property Value
SkipDuplicates
When true, the generated caretaker will skip capturing duplicate states (states that are equal according to value equality). Default is true. Only applies when GenerateCaretaker is true.
public bool SkipDuplicates { get; set; }