/// <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); }
/// <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); }
/// <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; }