public object Resolve(ScopeCache scopeCache)
            {
                switch (_lifetime)
                {
                case NSubLifetime.Transient:
                    return(_factory.Invoke(scopeCache));

                case NSubLifetime.Singleton:
                    return(_singletonValue ?? (_singletonValue = _factory.Invoke(scopeCache)));

                case NSubLifetime.PerScope:
                    if (scopeCache.TryGetValue(this, out var result))
                    {
                        return(result);
                    }

                    result = _factory.Invoke(scopeCache);
                    scopeCache.Set(this, result);
                    return(result);

                default:
                    throw new InvalidOperationException("Unknown lifetime.");
                }
            }