AppState
ConsoleMonster.Interactive
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
- Method ConsoleApp.Run
- Method ConsoleApp.RunAsync
- Property ConsoleAppOptions.ProcessEvents
Accepted by parameters 3
- Constructor AppBinding.AppBinding
- Method ConsoleApp.Run
- Method ConsoleApp.RunAsync
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
- 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
- The state key.
- fallback T? = null
- 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
- The key to locate.
- value object?
- 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.
Inherited Methods
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
- The state key.
Events
public event EventHandler<AppValueChangedEventArgs>? Changed #Raised after a changed value is committed, outside the dictionary lock.