UNPKG

@kephas/core

Version:

Provides a common infrastructure for all the other Kephas Framework components: ambient services, dynamic reflection, composition, application management, and others.

45 lines (44 loc) 1.63 kB
import 'reflect-metadata'; import { AppServiceInfoRegistry } from '../services/appServiceInfoRegistry'; import { AbstractType, Type } from '../type'; import { Injector } from './injector'; /** * Provides a container for the dependency injection. * * @export * @class LiteInjector */ export declare class LiteInjector extends Injector { private _registry; private _singletons; /** * Creates an instance of LiteInjector. * @param {AppServiceInfoRegistry} [registry] * @memberof LiteInjector */ constructor(registry?: AppServiceInfoRegistry); /** * Gets the service instance of the required service contract type. * * @template T * @param {Type<T>} type The service contract type. * @param notFoundResolver A resolver for the case when a type cannot be resolved. * @returns {T} The requested service. * @memberof LiteInjector */ resolve<T>(type: Type<T> | AbstractType, notFoundResolver?: (type: Type<T> | AbstractType) => any): T; /** * Gets an array of service instances. * * @template T * @param {Type<T>} type The service contract type. * @param notFoundResolver A resolver for the case when a type cannot be resolved. * @returns {T[]} The array of the requested service. * @memberof LiteInjector */ resolveMany<T>(type: Type<T> | AbstractType, notFoundResolver?: (type: Type<T> | AbstractType) => any): T[]; private _tryGetServiceContract; private _getServiceContract; private _getSingleServiceMetadata; private _createInstance; }