interfaces.ts
66 lines
| 1.5 KiB
| video/mp2t
|
TypeScriptLexer
|
|
r40 | import { isNull, isPrimitive } from "../safe"; | ||
|
|
r34 | import { ActivationContext } from "./ActivationContext"; | ||
|
|
r39 | import { Constructor, Factory } from "../interfaces"; | ||
|
|
r34 | |||
| export interface Descriptor { | ||||
| activate(context: ActivationContext, name?: string); | ||||
| } | ||||
|
|
r40 | export function isDescriptor(x): x is Descriptor { | ||
| return (!isPrimitive(x)) && | ||||
| (x.activate instanceof Function); | ||||
|
|
r34 | } | ||
| export interface ServiceMap { | ||||
|
|
r41 | [s: string]: Descriptor; | ||
|
|
r34 | } | ||
| export enum ActivationType { | ||||
|
|
r38 | Singleton, | ||
| Container, | ||||
| Hierarchy, | ||||
| Context, | ||||
| Call | ||||
| } | ||||
| export interface RegistrationWithServices { | ||||
| services?: object; | ||||
| } | ||||
| export interface ServiceRegistration extends RegistrationWithServices { | ||||
| $type?: string | Constructor; | ||||
| $factory?: string | Factory; | ||||
| activation?: "singleton" | "container" | "hierarchy" | "context" | "call"; | ||||
| params?; | ||||
| inject?: object | object[]; | ||||
| cleanup: (instance) => void | string; | ||||
| } | ||||
| export interface ValueRegistration { | ||||
| $value; | ||||
| parse?: boolean; | ||||
| } | ||||
| export interface DependencyRegistration extends RegistrationWithServices { | ||||
| $dependency: string; | ||||
| lazy?: boolean; | ||||
| optional?: boolean; | ||||
| default?; | ||||
| } | ||||
| export function isServiceRegistration(x): x is ServiceRegistration { | ||||
|
|
r40 | return (!isPrimitive(x)) && ("$type" in x || "$factory" in x); | ||
|
|
r38 | } | ||
| export function isValueRegistration(x): x is ValueRegistration { | ||||
|
|
r40 | return (!isPrimitive(x)) && ("$value" in x); | ||
|
|
r38 | } | ||
| export function isDependencyRegistration(x): x is DependencyRegistration { | ||||
|
|
r40 | return (!isPrimitive(x)) && ("$depdendency" in x); | ||
|
|
r38 | } | ||
