@kephas/core
Version:
Provides a common infrastructure for all the other Kephas Framework components: ambient services, dynamic reflection, composition, application management, and others.
42 lines (41 loc) • 1.38 kB
TypeScript
import { AbstractType, Type } from "../type";
/**
* Contract for composition context.
*
* @export
* @abstract
* @class Injector
*/
export declare abstract class Injector {
private static _instance;
/**
* Gets or sets the static instance of the Injector.
*
* @readonly
* @static
* @type {Injector}
* @memberof Injector
*/
static get instance(): Injector;
static set instance(value: Injector);
/**
* 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 Injector
*/
abstract 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 Injector
*/
abstract resolveMany<T>(type: Type<T> | AbstractType, notFoundResolver?: (type: Type<T> | AbstractType) => any): T[];
}