TurnState Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Per-turn state storage backed by a dictionary, supporting both key-value and typed object access. This type is not thread-safe; each instance is scoped to a single turn.
public class TurnState
type TurnState = class
Public Class TurnState
- Inheritance
-
TurnState
Constructors
| Name | Description |
|---|---|
| TurnState() |
Initializes a new, empty TurnState. |
Properties
| Name | Description |
|---|---|
| IsCompleted |
Returns true once this state scope has been sealed at end of turn. |
| IsDirty |
Returns true if any value has been added, modified, or removed since the state was loaded. |
| IsEmpty |
Returns true when the scope contains no values. |
Methods
| Name | Description |
|---|---|
| Clear() |
Removes every value from the scope. A persisted scope emptied this way is deleted from storage on save. |
| ContainsKey(String) |
Returns |
| FromDictionary(Dictionary<String,Object>) |
Creates a TurnState from an existing dictionary. Useful for testing. |
| FromJsonBytes(Byte[]) |
Deserializes a TurnState from a JSON byte array.
Returns an empty, non-dirty state when |
| Get<T>() |
Gets a typed state object. Creates a new instance via parameterless constructor if not present. |
| Get<T>(String) |
Gets a value by key. Returns |
| Has<T>() |
Returns |
| Remove(String) |
Removes a key from state. |
| Remove<T>() |
Removes the typed state object of this type. |
| Set<T>(String, T) |
Sets a value by key. |
| Set<T>(T) |
Sets a typed state object, replacing any existing instance of the same type. |
| ToJsonBytes() |
Serializes the state to a JSON byte array. |
| TryGet<T>(String, T) |
Attempts to get a value by key.
Returns |