예제 #1
0
        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <returns></returns>
        public override object GetValue()
        {
            IDictionary <PerRequestLifetimeManager, object> lifetimeManagers = UnityMvcApplication.GetPerRequestLifetimeManagers();
            object value;

            lifetimeManagers.TryGetValue(this, out value);

            return(value);
        }
예제 #2
0
        /// <summary>
        /// Removes the value.
        /// </summary>
        public override void RemoveValue()
        {
            IDictionary <PerRequestLifetimeManager, object> lifetimeManagers = UnityMvcApplication.GetPerRequestLifetimeManagers();

            object value;

            if (!lifetimeManagers.TryGetValue(this, out value))
            {
                return;
            }

            DisposeValue(value);
            lifetimeManagers.Remove(this);
        }
예제 #3
0
        /// <summary>
        /// Sets the value.
        /// </summary>
        /// <param name="newValue">The new value.</param>
        public override void SetValue(object newValue)
        {
            if (newValue == null)
            {
                RemoveValue();
                return;
            }

            IDictionary <PerRequestLifetimeManager, object> lifetimeManagers = UnityMvcApplication.GetPerRequestLifetimeManagers();
            object value;

            if (lifetimeManagers.TryGetValue(this, out value))
            {
                if ((value != null) && ReferenceEquals(value, newValue))
                {
                    // Setting the same object so exit
                    return;
                }

                DisposeValue(value);
            }

            lifetimeManagers[this] = newValue;
        }