Dependency injection container implementing IContainer.
Resolution order for a token:
- Provider registry — explicit DI registrations (class, factory, value).
- External resolver — when
autoRegisteris enabled and the token exists in the external source (ServiceRegistry), the instance is fetched and cached as a singleton for subsequent lookups. - Throw — if neither source has the token.
Circular dependencies are detected via an instance-level resolution stack
that persists across recursive resolve() calls (including factory
providers that call back into the container).
DiContainer(config: ContainerConfig)
Parameters
config: ContainerConfig
Container configuration
createScope(): IContainer
Creates a child scope. Scoped services resolve to one instance per scope; singletons are shared with the parent.
has(token: string): boolean
Reports whether a token is registered.
register<T>(token: string,provider: Provider<T>,options?: ProviderOptions): void
Registers a provider under a token.
resolve<T>(token: string): T
Resolves an instance, constructing it (and its dependencies) as needed.