Пример #1
0
        /// <inheritdoc/>
        /// <summary>
        /// See <see cref="IContextObject.Retrieve{T}()"/>
        /// </summary>
        public T Retrieve <T>()
        {
            if (TypedStorage.TryGetValue(typeof(T), out object value))
            {
                return((T)value);
            }

            return(default(T));
        }
Пример #2
0
        /// <inheritdoc/>
        /// <summary>
        /// See <see cref="IContextObject.TryRetrieve{T}(out T)"/>
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <returns></returns>
        public bool TryRetrieve <T>(out T value)
        {
            if (TypedStorage.TryGetValue(typeof(T), out object val))
            {
                value = (T)val;
                return(true);
            }

            value = default(T);
            return(false);
        }