Container Transient Lifetime
This lifetime is similar to Transient Lifetime with exception how the container holds references to created objects.
On each call to the
Resolve<T>() method a container will create a new objects. If the objects implements IDisposable, the container will hold a reference to the interface and will dispose the object when the container goes out of scope.
This lifetime is particularly useful in session based designs with child containers associated with the session.
The Lifetime Manager
Per container transient lifetime is controlled by ContainerControlledTransientManager type. This lifetime manager creates transient objects and holds reference to disposable instance and disposes these when container goes out of scope.
To create a Type registration with per container transient lifetime:
or you could register a factory:
container.RegisterFactory<IService>((c, t, n) => new Service(), FactoryLifetime.PerContainerTransient);