Add NULL as a first class citizen of the Unity Container
This commit is contained in:
Родитель
f55ee30026
Коммит
0d79a06eec
|
@ -65,7 +65,7 @@ namespace Unity.Strategies
|
|||
context.RequiresRecovery = recoveryPolicy;
|
||||
|
||||
var existing = policy.GetValue(context.Lifetime);
|
||||
if (existing != null)
|
||||
if (LifetimeManager.NoValue != existing)
|
||||
{
|
||||
context.Existing = existing;
|
||||
context.BuildComplete = true;
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace Unity
|
|||
try
|
||||
{
|
||||
// Validate input
|
||||
if (null == instance) throw new ArgumentNullException(nameof(instance));
|
||||
if (null == typeFrom) throw new InvalidOperationException($"At least one of Type arguments '{nameof(type)}' or '{nameof(instance)}' must be not 'null'");
|
||||
|
||||
if (null == lifetimeManager) lifetimeManager = new ContainerControlledLifetimeManager();
|
||||
if (((LifetimeManager)lifetimeManager).InUse) throw new InvalidOperationException(LifetimeManagerInUse);
|
||||
|
|
|
@ -440,7 +440,7 @@ namespace Unity
|
|||
|
||||
var lifetimeManager = (LifetimeManager)parentRef.Get(typeof(LifetimeManager));
|
||||
var result = lifetimeManager?.GetValue();
|
||||
if (null != result) return result;
|
||||
if (LifetimeManager.NoValue != result) return result;
|
||||
|
||||
throw new InvalidOperationException($"Circular reference for Type: {parentRef.Type}, Name: {parentRef.Name}",
|
||||
new CircularDependencyException());
|
||||
|
|
Загрузка…
Ссылка в новой задаче