@@ -8,6 +8,13 @@ namespace Unity.Lifetime
88 /// </summary>
99 public abstract class LifetimeManager
1010 {
11+ /// <summary>
12+ /// This value represents Invalid Value. Lifetime manager must return this value
13+ /// unless value is set to valid object. Null is a valie value and is not equal
14+ /// to NoValue
15+ /// </summary>
16+ public static readonly object NoValue = new InvalidValue ( ) ;
17+
1118 /// <summary>
1219 /// A <see cref="Boolean"/> indicating if this manager is being used in
1320 /// one of the registrations.
@@ -27,7 +34,7 @@ public abstract class LifetimeManager
2734 /// </summary>
2835 /// <param name="container">The container this lifetime is associated with</param>
2936 /// <returns>the object desired, or null if no such object is currently stored.</returns>
30- public abstract object GetValue ( ILifetimeContainer container = null ) ;
37+ public virtual object GetValue ( ILifetimeContainer container = null ) => NoValue ;
3138
3239 /// <summary>
3340 /// Stores the given value into backing store for retrieval later.
@@ -53,13 +60,6 @@ public virtual void RemoveValue(ILifetimeContainer container = null) { }
5360 /// <returns>A new instance of the appropriate lifetime manager</returns>
5461 public LifetimeManager CreateLifetimePolicy ( ) => OnCreateLifetimeManager ( ) ;
5562
56- /// <summary>
57- /// Type of current lifetime manager
58- /// </summary>
59- /// <returns>The <see cref="Type"/> of the manager.</returns>
60- [ Obsolete ( "This property will be removed in next major release. Use GetType() instead" , false ) ]
61- public Type LifetimeType => GetType ( ) ;
62-
6363 #endregion
6464
6565
@@ -72,5 +72,23 @@ public virtual void RemoveValue(ILifetimeContainer container = null) { }
7272 protected abstract LifetimeManager OnCreateLifetimeManager ( ) ;
7373
7474 #endregion
75+
76+
77+ #region Nested Types
78+
79+ public class InvalidValue
80+ {
81+ public override bool Equals ( object obj )
82+ {
83+ return ReferenceEquals ( this , obj ) ;
84+ }
85+
86+ public override int GetHashCode ( )
87+ {
88+ return base . GetHashCode ( ) ;
89+ }
90+ }
91+
92+ #endregion
7593 }
7694}
0 commit comments