Builds on the ContainerBase base class to introduce thread-safe caching of compiled targets so they are only compiled once per requested type.
Only creatable through inheritance.
public class CachingContainerBase : ContainerBase, IContainer, IScopeFactory, IServiceProvider, IRootTargetContainer, ITargetContainer, ICovariantTypeIndex
All the main IContainer implementations used directly in an application should ideally inherit from this class, because otherwise every Resolve(IResolveContext) operation would require a compilation phase before the object could be returned, which would be incredibly slow.
It's because of this caching that registering new targets in any ITargetContainer used by this class is not recommended: because after the first request for a particular type is made, the resultant ICompiledTarget is fixed until the container is thrown away.
Constructors| Improve this Doc View Source
Creates a new instance of the CachingContainerBase class.
protected CachingContainerBase(IRootTargetContainer targets = null)
Optional. The target container whose registrations will be used for dependency lookup when Resolve(IResolveContext) (and other operations) is called. If not provided, a new TargetContainer instance is constructed. This will ultimately be available to inherited types, after construction, through the Rezolver.Targets property.
Methods| Improve this Doc View Source
Obtains an ICompiledTarget for the given
protected override ICompiledTarget GetCompiledTargetVirtual(IResolveContext context)