##// END OF EJS Templates
configuration interfaces moved to di/Configuration module...
configuration interfaces moved to di/Configuration module ActivationType converted to string literals Working on annotations

File last commit:

r118:6738ac4c3072 ioc ts support
r118:6738ac4c3072 ioc ts support
Show More
FactoryServiceDescriptor.ts
21 lines | 742 B | video/mp2t | TypeScriptLexer
/ src / main / ts / di / FactoryServiceDescriptor.ts
import { ServiceDescriptor, ServiceDescriptorParams } from "./ServiceDescriptor";
import { argumentNotNull, oid } from "../safe";
export interface FactoryServiceDescriptorParams<S, T, P extends any[]> extends ServiceDescriptorParams<S, T, P> {
factory: (...args: P) => T;
}
export class FactoryServiceDescriptor<S, T, P extends any[]> extends ServiceDescriptor<S, T, P> {
constructor(opts: FactoryServiceDescriptorParams<S, T, P>) {
super(opts);
argumentNotNull(opts && opts.factory, "opts.factory");
// bind to null
this._factory = (...args) => opts.factory.apply(null, args as any);
if (opts.activation === "singleton") {
this._cacheId = oid(opts.factory);
}
}
}