Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
UndoToken.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.ActionStack
6 {
7  /// <summary>
8  /// Represents a token that stores an unique identifier and an object. This token should be generated by
9  /// a cancellable command and be passed as argument when the command must be undone.
10  /// </summary>
11  /// <remarks>This object is immutable.</remarks>
12  public struct UndoToken
13  {
14  private readonly Guid guid;
15  private readonly bool canUndo;
16  private readonly object tokenValue;
17 
18  /// <summary>
19  /// Initializes a new instance of the <see cref="UndoToken"/> structure with some parameters.
20  /// </summary>
21  /// <param name="canUndo">Indicate if this token corresponds to an action that can be undone.</param>
22  /// <param name="tokenValue">The object stored in this token which can be used to undo the associated action (such as previous value of a property).</param>
23  public UndoToken(bool canUndo, object tokenValue = null)
24  {
25  guid = Guid.NewGuid();
26  this.canUndo = canUndo;
27  this.tokenValue = tokenValue;
28  }
29 
30  /// <summary>
31  /// Gets a unique identifier for the token.
32  /// </summary>
33  public Guid Guid { get { return guid; } }
34 
35  /// <summary>
36  /// Gets whether this token represents an action that can actually be undone.
37  /// </summary>
38  public bool CanUndo { get { return canUndo; } }
39 
40  /// <summary>
41  /// Gets a user-defined object hosted by the token that should store all information needed to undo a command.
42  /// </summary>
43  public object TokenValue { get { return tokenValue; } }
44  }
45 }
UndoToken(bool canUndo, object tokenValue=null)
Initializes a new instance of the UndoToken structure with some parameters.
Definition: UndoToken.cs:23
Represents a token that stores an unique identifier and an object. This token should be generated by ...
Definition: UndoToken.cs:12