private ILifetime GetLifetime(TypeDescriptor typeDescriptor) { if (Lifetime == null) { return(null); } if (!typeDescriptor.IsConstructedGenericType()) { return(Lifetime); } var lifetimeKey = new LifetimeKey(typeDescriptor.GetGenericTypeArguments()); ILifetime lifetime; lock (_lockObject) { if (!_lifetimes.TryGetValue(lifetimeKey, out lifetime)) { lifetime = Lifetime.Create(); _lifetimes.Add(lifetimeKey, lifetime); } } return(lifetime); }
// Creates the similar lifetime to use with generic instances public ILifetime Create() => new MySingletonLifetime(_baseSingletonLifetime.Create(), _counter);