@@ -6,7 +6,7 @@ namespace Unity.Lifetime
66 /// A <see cref="LifetimeManager"/> that holds a weak reference to
77 /// it's managed instance.
88 /// </summary>
9- public class ExternallyControlledLifetimeManager : LifetimeManager ,
9+ public class ExternallyControlledLifetimeManager : SynchronizedLifetimeManager ,
1010 IInstanceLifetimeManager ,
1111 ITypeLifetimeManager ,
1212 IFactoryLifetimeManager
@@ -18,35 +18,36 @@ public class ExternallyControlledLifetimeManager : LifetimeManager,
1818 #endregion
1919
2020
21- #region Overrides
21+ #region SynchronizedLifetimeManager
2222
23- /// <summary>
24- /// Retrieve a value from the backing store associated with this Lifetime policy.
25- /// </summary>
26- /// <param name="container">Instance of container requesting the value</param>
27- /// <returns>the object desired, or null if no such object is currently stored.</returns>
28- public override object GetValue ( ILifetimeContainer container = null )
23+ /// <inheritdoc/>
24+ protected override object SynchronizedGetValue ( ILifetimeContainer container = null )
2925 {
3026 if ( null == _value ) return NoValue ;
3127
3228 var target = _value . Target ;
33- if ( _value . IsAlive ) return target ;
29+ if ( null != target ) return target ;
3430
3531 _value = null ;
3632
3733 return NoValue ;
3834 }
3935
40- /// <summary>
41- /// Stores the given value into backing store for retrieval later.
42- /// </summary>
43- /// <param name="container">Instance of container which owns the value</param>
44- /// <param name="newValue">The object being stored.</param>
45- public override void SetValue ( object newValue , ILifetimeContainer container = null )
36+ /// <inheritdoc/>
37+ protected override void SynchronizedSetValue ( object newValue , ILifetimeContainer container = null )
4638 {
4739 _value = new WeakReference ( newValue ) ;
4840 }
4941
42+
43+ /// <inheritdoc/>
44+ public override void RemoveValue ( ILifetimeContainer container = null ) => _value = null ;
45+
46+ #endregion
47+
48+
49+ #region Overrides
50+
5051 protected override LifetimeManager OnCreateLifetimeManager ( )
5152 {
5253 return new ExternallyControlledLifetimeManager ( ) ;
0 commit comments