Class State<TKey, TValue>
An implementation of IState<TKey, TValue> from a function to query and retrieve an object.
Inherited Members
Namespace: Microsoft.XboxStudios.GameStateTracker
Assembly: GameStateTracker.Core.dll
Syntax
public class State<TKey, TValue> : StateBase<TKey, TValue>, IState<TKey, TValue>, IReadOnlyCollection<TValue>, IEnumerable<TValue>, IEnumerable, IHasUpdateTime, IDisposable where TKey : IEquatable<TKey> where TValue : class
Type Parameters
Name | Description |
---|---|
TKey | The key type to query for an object. |
TValue | The object type. |
Remarks
The query does not need to be thread-safe as it won't be called concurrently.
Constructors
View SourceState(Func<TKey, Task<TValue>>, IObjectCache<TKey, TValue>?, ILogger<State<TKey, TValue>>?)
An implementation of IState<TKey, TValue> from a function to query and retrieve an object.
Declaration
public State(Func<TKey, Task<TValue>> get, IObjectCache<TKey, TValue>? cache = null, ILogger<State<TKey, TValue>>? logger = null)
Parameters
Type | Name | Description |
---|---|---|
Func<TKey, Task<TValue>> | get | The function to query an object. |
IObjectCache<TKey, TValue> | cache | The cache to use to store objects. |
ILogger<State<TKey, TValue>> | logger | The logger to use. |
Remarks
The query does not need to be thread-safe as it won't be called concurrently.
Methods
View SourceGetObject(TKey, CancellationToken)
Retrieves an object matching the given query.
Declaration
protected override Task<TValue?> GetObject(TKey query, CancellationToken token)
Parameters
Type | Name | Description |
---|---|---|
TKey | query | The objects to look for. |
CancellationToken | token | The cancellation token. |
Returns
Type | Description |
---|---|
Task<TValue> | An object. |