/// <summary> /// Sets a static property to be stored within context. /// </summary> public void SetProperty <T>(T value) { var idx = StaticIndexes.StaticsIndex <T>(); EnsureStaticsSize(idx); _statics[idx] = value; }
/// <summary> /// Tries to get a static property stored within context. /// </summary> public T TryGetProperty <T>() where T : class { var idx = StaticIndexes.StaticsIndex <T>(); EnsureStaticsSize(idx); return(_statics[idx] as T); }
/// <summary> /// Gets context static object of type <typeparamref name="T"/>. /// </summary> /// <typeparam name="T">Type of the object to be stored within context.</typeparam> public T GetStatic <T>() where T : new() => GetStatic <T>(StaticIndexes.StaticsIndex <T>());
/// <summary> /// Tries to get a static property stored within context. /// </summary> public T TryGetProperty <T>() where T : class { var idx = StaticIndexes.StaticsIndex <T>(); var statics = _statics; return(idx < statics.Length ? statics[idx] as T : default);