Class TimeElapsedHelper<TKey>
A helper class used to associate objects with a DateTime value and to compare against the current time.
Inherited Members
Namespace: Microsoft.XboxStudios.GameStateTracker.Cache
Assembly: GameStateTracker.Core.dll
Syntax
public class TimeElapsedHelper<TKey> where TKey : notnull
Type Parameters
Name | Description |
---|---|
TKey | The object type. |
Properties
View SourceKeys
Gets a collections of the objects with an existing refresh time.
Declaration
public ICollection<TKey> Keys { get; }
Property Value
Type | Description |
---|---|
ICollection<TKey> |
Methods
View SourceIsOlderThan(TKey, TimeSpan, DateTime?)
Compares the time elapsed since the object's start time to a value.
Declaration
public bool IsOlderThan(TKey item, TimeSpan maxAge, DateTime? now = null)
Parameters
Type | Name | Description |
---|---|---|
TKey | item | The object. |
TimeSpan | maxAge | The value to compare against. |
DateTime? | now | The current time to use. |
Returns
Type | Description |
---|---|
bool | True if the object's start time is greater than the value to compare against. |
Refresh(TKey)
Sets the object's start time to the current time.
Declaration
public void Refresh(TKey item)
Parameters
Type | Name | Description |
---|---|---|
TKey | item | The object. |
Remove(TKey)
Removes an object's start time.
Declaration
public void Remove(TKey item)
Parameters
Type | Name | Description |
---|---|---|
TKey | item | The object. |
Set(TKey, DateTime)
Sets the object's start time.
Declaration
public void Set(TKey item, DateTime value)
Parameters
Type | Name | Description |
---|---|---|
TKey | item | The object. |
DateTime | value | The start time. |
TryGet(TKey)
Gets the time elapsed since an object's start time.
Declaration
public TimeSpan? TryGet(TKey item)
Parameters
Type | Name | Description |
---|---|---|
TKey | item | The object. |
Returns
Type | Description |
---|---|
TimeSpan? | The time elapsed since the object's start time. |
TryGet(TKey, DateTime)
Gets the time elapsed since an object's start time.
Declaration
public TimeSpan? TryGet(TKey item, DateTime now)
Parameters
Type | Name | Description |
---|---|---|
TKey | item | The object. |
DateTime | now | The current time to use. |
Returns
Type | Description |
---|---|
TimeSpan? | The time elapsed since the object's start time. |