Skip to content
ConsoleMonster
Class

AppState

ConsoleMonster.Interactive

Namespace
ConsoleMonster.Interactive
Assembly
ConsoleMonster
Implements
IReadOnlyDictionary<string, object> IReadOnlyCollection<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>> IEnumerable
Modifiers
sealed
Attributes
DefaultMember("Item")

Thread-safe named values shared by an application and its dependent views. Enumeration takes a snapshot.

Inheritance

  • object
  • AppState

Usage

Explore 6 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 3

Accepted by parameters 3

Constructors

public AppState() #

Methods

public bool ContainsKey(string key) #

Determines whether the read-only dictionary contains an element that has the specified key.

Parameters

key string required
The key to locate.

Returns

bool true if the read-only dictionary contains an element that has the specified key; otherwise, false.

Exceptions

  • ArgumentNullException – key is null.
public IEnumerator<KeyValuePair<string, object?>> GetEnumerator() #

Returns an enumerator that iterates through the collection.

Returns

IEnumerator<KeyValuePair<string, object?>> An enumerator that can be used to iterate through the collection.
public T? Get<T>(string key, T? fallback = null) #

Reads a typed value, returning a fallback when the key is absent or has another type.

Type Parameters

T
The expected type.

Parameters

key string required
The state key.
fallback T? = null optional
The value to use when the typed value is unavailable.

Returns

T? The typed value.
public void RequestExit() #

Requests an orderly exit after pending input callbacks finish.

public IReadOnlyDictionary<string, object?> Snapshot() #

Copies the current values into a read-only dictionary.

Returns

IReadOnlyDictionary<string, object?> A stable dictionary snapshot.
public bool TryGetValue(string key, out object? value) #

Gets the value that is associated with the specified key.

Parameters

key string required
The key to locate.
value object? required
When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.

Returns

bool true if the object that implements the IReadOnlyDictionary<T1, T2> interface contains an element that has the specified key; otherwise, false.

Exceptions

  • ArgumentNullException – key is null.

Properties

public object? this[string key] { get; set; } #

Gets or sets a named value; assigning an equal value does not raise a notification.

Parameters

key string required
The state key.
public int Count { get; } #

The current key count.

public IEnumerable<string> Keys { get; } #

A snapshot of the keys.

public IEnumerable<object?> Values { get; } #

A snapshot of the values.

public bool ExitRequested { get; } #

Whether a callback requested that the app finish.

Events

public event EventHandler<AppValueChangedEventArgs>? Changed #

Raised after a changed value is committed, outside the dictionary lock.