import type { IDependencyContainer, ConfigurableDependency, DependencyFactoryCallback } from './IDependencyContainer'; import { type IDependencyResolver, type ResolvableSimpleDependency, type ComplexDependency, DependencyToken } from './IDependencyResolver'; /** * Represents a dependency container for configuring and later on resolving dependencies similar to a dependency injection mechanism. */ export declare class DependencyContainer implements IDependencyContainer, IDependencyResolver { private static _dependencyResolutionChain; private readonly _parent; private readonly _singletonDependencyFactories; private readonly _scopedDependencyFactories; /** * Initializes a new instance of the {@linkcode DependencyContainer} class. * @param parent Optional, a parent container to use as fallback when resolving dependencies. */ constructor(parent?: DependencyContainer); /** * Creates a scoped dependency resolver. All scoped configured dependencies are resolved for each scope individually, * while singletons are unique from the scope that configured them downwards. * @returns Returns a scoped dependency resolver. */ createScope(): IDependencyResolver; /** * Registers the provided type as a singleton dependency. * @template T The dependency type to configure. * @param type The type to configure. * @returns Returns the dependency container. */ registerSingletonType(type: ConfigurableDependency): DependencyContainer; /** * Registers the provided type as a singleton dependency. * @template T The dependency type to configure. * @param type The type to configure. * @param factoryCallback A callback for initializing an instace of the given type. * @returns Returns the dependency container. */ registerSingletonType(type: ConfigurableDependency, factoryCallback: DependencyFactoryCallback): DependencyContainer; /** * Registers the provided instance for the given token. * @template T The dependency type to configure. * @param token The token used to resolve dependencies. * @param instance The instance to return when resolving the dependency token. * @returns Returns the dependency container. */ registerInstanceToToken(token: DependencyToken, instance: T): DependencyContainer; /** * Registers the provided type for the given token as a singleton dependency. * @template T The dependency type to configure. * @param token The token used to resolve dependencies. * @param type The type to configure. * @returns Returns the dependency container. */ registerSingletonTypeToToken(token: DependencyToken, type: ConfigurableDependency): DependencyContainer; /** * Registers the provided callback for the given token as a singleton dependency. * @template T The dependency type to configure. * @param token The token used to resolve dependencies. * @param factoryCallback A callback for initializing an instace of the given type. * @returns Returns the dependency container. */ registerSingletonFactoryToToken(token: DependencyToken, factoryCallback: DependencyFactoryCallback): DependencyContainer; /** * Registers the provided type as a scoped dependency. * @template T The dependency type to configure. * @param type The type to configure. * @returns Returns the dependency container. */ registerScopedType(type: ConfigurableDependency): DependencyContainer; /** * Registers the provided type as a scoped dependency. * @template T The dependency type to configure. * @param type The type to configure. * @param factoryCallback A callback for initializing an instace of the given type. * @returns Returns the dependency container. */ registerScopedType(type: ConfigurableDependency, factoryCallback: DependencyFactoryCallback): DependencyContainer; /** * Registers the provided type for the given token as a scoped dependency. * @template T The dependency type to configure. * @param token The token used to resolve dependencies. * @param type The type to configure. * @returns Returns the dependency container. */ registerScopedTypeToToken(token: DependencyToken, type: ConfigurableDependency): DependencyContainer; /** * Registers the provided callback for the given token as a scoped dependency. * @template T The dependency type to configure. * @param token The token used to resolve dependencies. * @param factoryCallback A callback for initializing an instace of the given type. * @returns Returns the dependency container. */ registerScopedFactoryToToken(token: DependencyToken, factoryCallback: DependencyFactoryCallback): DependencyContainer; /** * Registers the provided type as a transient dependency. * @template T The dependency type to configure. * @param type The type to configure. * @param factoryCallback A callback for initializing an instace of the given type. * @returns Returns the dependency container. */ registerTransientType(type: ConfigurableDependency, factoryCallback: DependencyFactoryCallback): DependencyContainer; /** * Registers the provided type for the given token as a transient dependency. * @template T The dependency type to configure. * @param token The token used to resolve dependencies. * @param type The type to configure. * @returns Returns the dependency container. */ registerTransientTypeToToken(token: DependencyToken, type: ConfigurableDependency): DependencyContainer; /** * Registers the provided callback for the given token as a transient dependency. * @template T The dependency type to configure. * @param token The token used to resolve dependencies. * @param factoryCallback A callback for initializing an instace of the given type. * @returns Returns the dependency container. */ registerTransientFactoryToToken(token: DependencyToken, factoryCallback: DependencyFactoryCallback): DependencyContainer; /** * Resolves a dependency based on its configuration, if any. All unconfigured dependencies are transient. * * @template T The dependency type to resolve. * * @param dependency The dependnecy to resolve. * * @returns The resolved dependency. */ resolve(dependency: ResolvableSimpleDependency): T; /** * Resolves a dependency based on its configuration, if any. All unconfigured dependencies are transient. * * @template T The dependency type to resolve. * * @param dependency The dependnecy to resolve. * * @returns The resolved dependency. * * @ignore This is overload is not relevant for wiki documentation. */ resolve(dependency: ResolvableSimpleDependency | null): T | null; /** * Resolves a dependency based on its configuration, if any. All unconfigured dependencies are transient. * * @template T The dependency type to resolve. * * @param dependency The dependnecy to resolve. * * @returns The resolved dependency. * * @ignore This is overload is not relevant for wiki documentation. */ resolve(dependency: ResolvableSimpleDependency | undefined): T | undefined; /** * Resolves a dependency based on its configuration, if any. All unconfigured dependencies are transient. * * @template T The dependency type to resolve. * * @param dependency The dependnecy to resolve. * * @returns The resolved dependency. * * @ignore This is overload is not relevant for wiki documentation. */ resolve(dependency: ResolvableSimpleDependency | null | undefined): T | null | undefined; /** * Resolves a complex dependency. All such dependencies are transient as they require * additional dependencies on the constructor. * * @template T The dependency type to resolve. * @template TAdditional A tuple representing additional parameters required by the constructor. * * @param dependency The complex dependnecy to resolve. * @param additionalDependencies Additional dependencies requested by the constructor besides the dependency resolver. * * @returns The resolved dependency. */ resolve(dependency: ComplexDependency, additionalDependencies: TAdditional): T; /** * Resolves a complex dependency. All such dependencies are transient as they require * additional dependencies on the constructor. * * @template T The dependency type to resolve. * @template TAdditional A tuple representing additional parameters required by the constructor. * * @param dependency The complex dependnecy to resolve. * @param additionalDependencies Additional dependencies requested by the constructor besides the dependency resolver. * * @returns The resolved dependency. * * @ignore This is overload is not relevant for wiki documentation. */ resolve(dependency: ComplexDependency | null, additionalDependencies: TAdditional): T | null; /** * Resolves a complex dependency. All such dependencies are transient as they require * additional dependencies on the constructor. * * @template T The dependency type to resolve. * @template TAdditional A tuple representing additional parameters required by the constructor. * * @param dependency The complex dependnecy to resolve. * @param additionalDependencies Additional dependencies requested by the constructor besides the dependency resolver. * * @returns The resolved dependency. * * @ignore This is overload is not relevant for wiki documentation. */ resolve(dependency: ComplexDependency | undefined, additionalDependencies: TAdditional): T | undefined; /** * Resolves a complex dependency. All such dependencies are transient as they require * additional dependencies on the constructor. * * @template T The dependency type to resolve. * @template TAdditional A tuple representing additional parameters required by the constructor. * * @param dependency The complex dependnecy to resolve. * @param additionalDependencies Additional dependencies requested by the constructor besides the dependency resolver. * * @returns The resolved dependency. * * @ignore This is overload is not relevant for wiki documentation. */ resolve(dependency: ComplexDependency | null | undefined, additionalDependencies: TAdditional): T | null | undefined; }