Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }