Class States
- Namespace
- OverKizApi.Models
- Assembly
- OverKizApi.dll
An ordered, name-indexed collection of State objects for a device. Implements IEnumerable<T> so it can be used directly in foreach loops.
[JsonConverter(typeof(StatesJsonConverter))]
public sealed class States : IEnumerable<State>, IEnumerable
- Inheritance
-
States
- Implements
- Inherited Members
Remarks
Initialises the collection from an optional sequence of states.
Constructors
States(IEnumerable<State>?)
An ordered, name-indexed collection of State objects for a device. Implements IEnumerable<T> so it can be used directly in foreach loops.
public States(IEnumerable<State>? states = null)
Parameters
statesIEnumerable<State>Initial states; pass null or omit for an empty collection.
Remarks
Initialises the collection from an optional sequence of states.
Properties
this[string]
public State? this[string name] { get; }
Parameters
namestringQualified state name (e.g.
"core:ClosureState").
Property Value
Methods
Contains(string)
Returns true if a state with the given qualified name is present.
public bool Contains(string name)
Parameters
namestringQualified state name to look up.
Returns
- bool
True if the named state exists; otherwise false.
FirstValueAsBool(IEnumerable<string>)
Returns the first non-null value in name order as a boolean. A wrong type throws.
public bool? FirstValueAsBool(IEnumerable<string> names)
Parameters
namesIEnumerable<string>The qualified state names to try, in priority order.
Returns
- bool?
The first non-null Boolean value in name order; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
FirstValueAsDict(IEnumerable<string>)
Returns the first non-null value in name order as a CLR dictionary. A wrong type throws.
public IReadOnlyDictionary<string, object?>? FirstValueAsDict(IEnumerable<string> names)
Parameters
namesIEnumerable<string>The qualified state names to try, in priority order.
Returns
- IReadOnlyDictionary<string, object>
The first non-null dictionary value in name order; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
FirstValueAsFloat(IEnumerable<string>)
Returns the first non-null value in name order as a float, promoting integers. A wrong type throws.
public double? FirstValueAsFloat(IEnumerable<string> names)
Parameters
namesIEnumerable<string>The qualified state names to try, in priority order.
Returns
- double?
The first non-null floating-point value in name order; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
FirstValueAsInt(IEnumerable<string>)
Returns the first non-null value in name order as an integer. A wrong type throws; later names are not tried.
public int? FirstValueAsInt(IEnumerable<string> names)
Parameters
namesIEnumerable<string>The qualified state names to try, in priority order.
Returns
- int?
The first non-null integer value in name order; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
FirstValueAsList(IEnumerable<string>)
Returns the first non-null value in name order as a CLR list. A wrong type throws.
public IReadOnlyList<object?>? FirstValueAsList(IEnumerable<string> names)
Parameters
namesIEnumerable<string>The qualified state names to try, in priority order.
Returns
- IReadOnlyList<object>
The first non-null list value in name order; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
FirstValueAsStr(IEnumerable<string>)
Returns the first non-null value in name order as a string. A wrong type throws.
public string? FirstValueAsStr(IEnumerable<string> names)
Parameters
namesIEnumerable<string>The qualified state names to try, in priority order.
Returns
- string
The first non-null string value in name order; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
GetEnumerator()
Enumerates the states in collection order.
public IEnumerator<State> GetEnumerator()
Returns
- IEnumerator<State>
An enumerator over the stored states.
GetValueAsBool(string)
Returns a named boolean value, or null if missing or null. A wrong type throws InvalidCastException.
public bool? GetValueAsBool(string name)
Parameters
namestringThe qualified state name to look up.
Returns
- bool?
The named Boolean value; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
GetValueAsDict(string)
Returns a named CLR dictionary, or null if missing or null. A wrong type throws InvalidCastException.
public IReadOnlyDictionary<string, object?>? GetValueAsDict(string name)
Parameters
namestringThe qualified state name to look up.
Returns
- IReadOnlyDictionary<string, object>
The named dictionary value; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
GetValueAsFloat(string)
Returns a named floating-point value, promoting integers; null if missing or null. A wrong type throws InvalidCastException.
public double? GetValueAsFloat(string name)
Parameters
namestringThe qualified state name to look up.
Returns
- double?
The named floating-point value; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
GetValueAsInt(string)
Returns a named integer value, or null if missing or null. A wrong type throws InvalidCastException.
public int? GetValueAsInt(string name)
Parameters
namestringThe qualified state name to look up.
Returns
- int?
The named integer value; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
GetValueAsList(string)
Returns a named CLR list, or null if missing or null. A wrong type throws InvalidCastException.
public IReadOnlyList<object?>? GetValueAsList(string name)
Parameters
namestringThe qualified state name to look up.
Returns
- IReadOnlyList<object>
The named list value; null if no non-null state value is found. An incompatible value type throws an InvalidCastException.
GetValueAsStr(string)
Returns a named string value, or null if missing or null. A wrong type throws InvalidCastException.
public string? GetValueAsStr(string name)
Parameters
namestringThe qualified state name to look up.