Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed Oct 9, 2020
1 parent 8c50ad5 commit 25c0fdf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion VContainer/Assets/VContainer/Runtime/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ public object Resolve(IRegistration registration)
return registration.SpawnInstance(this);

case Lifetime.Singleton:
if (Parent is null)
{
return Root.Resolve(registration);
}
if (registry.Exists(registration))
{
return sharedInstances.GetOrAdd(registration, createInstance).Value;
}
return (Parent.Parent is null ? Parent.Root : Parent).Resolve(registration);
return Parent.Resolve(registration);

case Lifetime.Scoped:
var lazy = sharedInstances.GetOrAdd(registration, createInstance);
Expand Down

0 comments on commit 25c0fdf

Please sign in to comment.