@kephas/core
Version:
Provides a common infrastructure for all the other Kephas Framework components: ambient services, dynamic reflection, composition, application management, and others.
123 lines (122 loc) • 3.6 kB
TypeScript
import { Injector } from "../injection/injector";
import { Type } from "../type";
import { AppServiceInfo } from "./appServiceInfo";
/**
* Enumerates the priority values.
* They are practically a convenient way to provide integer values for defining priorities.
* A lower value indicates a higher priority.
*
* @export
* @enum {number}
*/
export declare enum Priority {
/**
* The lowest priority. Typically used by the null services.
*/
Lowest = 2147483647,
/**
* The low priority. Typically used by the default services.
*/
Low = 1000000,
/**
* The below normal priority. Typically used by services with a higher specialization than the default ones.
*/
BelowNormal = 1000,
/**
* The normal priority (the default).
*/
Normal = 0,
/**
* The above normal priority.
*/
AboveNormal = -1000,
/**
* The high priority.
*/
High = -1000000,
/**
* The highest priority.
*/
Highest = -2147483648
}
/**
* Metadata for application services.
*
* @export
* @class AppServiceMetadata
*/
export declare class AppServiceMetadata<T> {
/**
* Gets the override priority.
*
* @type {number}
* @memberof AppServiceInfo
*/
readonly overridePriority: number;
/**
* Gets the processing priority.
*
* @type {number}
* @memberof AppServiceInfo
*/
readonly processingPriority: number;
/**
* Gets the service name.
*
* @type {string}
* @memberof AppServiceMetadata
*/
readonly serviceName?: string;
/**
* Gets the service implementation type.
*
* @type {Function}
* @memberof AppServiceMetadata
*/
get serviceType(): Type<T> | undefined;
/**
* Gets the application service contract information.
*
* @type {AppServiceInfo}
* @memberof AppServiceMetadata
*/
get serviceContract(): AppServiceInfo | undefined;
/**
* Gets the service instance.
*
* @type {T}
* @memberof AppServiceMetadata
*/
get serviceInstance(): T | undefined;
/**
* Gets or sets the service factory.
*
* @type {(c: Injector) => T}
* @memberof AppServiceMetadata
*/
readonly serviceFactory?: (c: Injector) => T;
private _serviceContract?;
private _serviceType?;
private _serviceInstance?;
/**
* Creates an instance of AppServiceMetadata.
*
* @param {number|Priority} [overridePriority=Priority.Normal] Optional. The override priority.
* @param {number|Priority} [processingPriority=Priority.Normal] Optional. The processing priority.
* @param {string} [serviceName] Optional. The service name.
* @param {Type<T>} [serviceType] Optional. The service implementation type.
* @param {() => T} [serviceFactory] Optional. The service factory.
* @param {T} [serviceInstance] Optional. The service instance.
* @param {AppServiceInfo} [serviceContract] Optional. The service contract.
* @memberof AppServiceMetadata
*/
constructor({ overridePriority, processingPriority, serviceName, serviceType, serviceFactory, serviceInstance, ...args }?: {
overridePriority?: number | Priority;
processingPriority?: number | Priority;
serviceName?: string;
serviceType?: Type<T>;
serviceFactory?: (c: Injector) => T;
serviceInstance?: T;
[key: string]: any;
});
}