##// END OF EJS Templates
Added childContainer service to container services, ServiceContaier is destroyable, fixed browser Uuid version
Added childContainer service to container services, ServiceContaier is destroyable, fixed browser Uuid version

File last commit:

r129:c13384c6c1ac ioc ts support
r146:f3f5c56d3b3e v1.4.0-rc5 default
Show More
AggregateDescriptor.ts
40 lines | 1.0 KiB | video/mp2t | TypeScriptLexer
/ src / main / ts / di / AggregateDescriptor.ts
import { Descriptor } from "./interfaces";
import { ActivationContext } from "./ActivationContext";
import { isPrimitive } from "../safe";
import { isDescriptor } from "./traits";
export class AggregateDescriptor<S extends object, T> implements Descriptor<S, T> {
_value: any;
constructor(value: any) {
this._value = value;
}
activate(context: ActivationContext<S>): T {
return this._parse(this._value, context, "$value");
}
_parse(value: any, context: ActivationContext<S>, path: string): any {
if (isPrimitive(value))
return value as any;
if (isDescriptor(value))
return context.activate(value, path);
if (value instanceof Array)
return value.map((x, i) => this._parse(x, context, `${path}[${i}]`)) as any;
const t: any = {};
for (const p in value)
t[p] = this._parse(value[p], context, `${path}.${p}`);
return t;
}
toString() {
return "@walk";
}
clone() {
return this;
}
}