Ejemplo n.º 1
0
        /// <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;
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 /// <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>());
Ejemplo n.º 4
0
        /// <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);