Show / Hide Table of Contents

Class TimeElapsedHelper<TKey>

A helper class used to associate objects with a DateTime value and to compare against the current time.

Inheritance
object
TimeElapsedHelper<TKey>
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
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 Source

Keys

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 Source

IsOlderThan(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.

View Source

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.

View Source

Remove(TKey)

Removes an object's start time.

Declaration
public void Remove(TKey item)
Parameters
Type Name Description
TKey item

The object.

View Source

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.

View Source

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.

View Source

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.

  • View Source
In this article
Back to top Generated by DocFX