@kephas/core
Version:
Provides a common infrastructure for all the other Kephas Framework components: ambient services, dynamic reflection, composition, application management, and others.
96 lines (95 loc) • 3.45 kB
TypeScript
import 'reflect-metadata';
import { AbstractType, Type } from '../type';
import { AppServiceInfo } from './appServiceInfo';
import { AppServiceMetadata } from './appServiceMetadata';
/**
* Registry for the application service information.
*
* @export
* @class AppServiceInfoRegistry
*/
export declare class AppServiceInfoRegistry {
private static readonly _serviceContractKey;
private static readonly _serviceMetadataKey;
private static _instance;
/**
* Gets the static instance of the registry.
*
* @static
* @memberof AppServiceInfoRegistry
*/
static get Instance(): AppServiceInfoRegistry;
private readonly _serviceContracts;
private readonly _services;
/**
* Creates an instance of AppServiceInfoRegistry.
* @memberof AppServiceInfoRegistry
*/
constructor();
/**
* Gets an iterator over service contracts.
*
* @returns {IterableIterator<AppServiceInfo>} The iterator over service contracts.
* @memberof AppServiceInfoRegistry
*/
get serviceContracts(): IterableIterator<AppServiceInfo>;
/**
* Gets an iterator of services.
*
* @readonly
* @type {IterableIterator<AppServiceMetadata>} The iterator over services.
* @memberof AppServiceInfoRegistry
*/
get services(): IterableIterator<AppServiceMetadata<any>>;
/**
* Registers the provided type as a service contract.
*
* @static
* @param {AbstractType} type The type to be registered.
* @param {AppServiceInfo} appServiceInfo The service information.
* @memberof AppServiceInfoRegistry
*/
registerServiceContract(type: AbstractType, appServiceInfo: AppServiceInfo): this;
/**
* Registers the provided type as a service type.
*
* @static
* @param {Type<T>} type The type to be registered.
* @param {AppServiceMetadata} [metadata] Optional. The service metadata.
* @memberof AppServiceInfoRegistry
*/
registerService<T>(type: Type<T>, metadata?: AppServiceMetadata<T>): this;
/**
* Gets the service contract from the provided type, if possible.
*
* @param {AbstractType} type The type assumed to be a service contract or a service type.
* @returns {(AppServiceInfo | null)} The AppServiceInfo instance or null, if the type is not a service contract.
* @memberof AppServiceInfoRegistry
*/
getServiceContract(type: AbstractType): AppServiceInfo | null;
/**
* Gets a value indicating whether a type is a service contract.
*
* @param {AbstractType} type The type assumed to be a service contract.
* @returns {boolean}
* @memberof AppServiceInfoRegistry
*/
isServiceContract(type: AbstractType): boolean;
/**
* Gets the service metadata from the provided type, if possible.
*
* @param {AbstractType} type The type assumed to be a service type.
* @returns {(AppServiceMetadata | null)}
* @memberof AppServiceInfoRegistry
*/
getServiceMetadata(type: AbstractType): AppServiceMetadata<any> | null;
/**
* Gets a value indicating whether a type is a service.
*
* @param {AbstractType} type
* @returns {boolean}
* @memberof AppServiceInfoRegistry
*/
isService(type: AbstractType): boolean;
private _getContractOfService;
}