##// END OF EJS Templates
sync
sync

File last commit:

r115:691199f665e0 ioc ts support
r117:6149d2260004 ioc ts support
Show More
AggregateDescriptor.ts
35 lines | 986 B | video/mp2t | TypeScriptLexer
/ src / main / ts / di / AggregateDescriptor.ts
cin
corrected code to support ts strict mode...
r115 import { Descriptor, isDescriptor, Parse } from "./interfaces";
cin
changed the project structure
r49 import { ActivationContext } from "./ActivationContext";
import { isPrimitive } from "../safe";
cin
working on IoC configuration
r114 export class AggregateDescriptor<T> implements Descriptor<Parse<T>> {
cin
working on IoC configuration
r113 _value: T;
cin
changed the project structure
r49
cin
working on IoC configuration
r113 constructor(value: T) {
cin
changed the project structure
r49 this._value = value;
}
cin
working on IoC configuration
r114 activate<S>(context: ActivationContext<S>) {
cin
changed the project structure
r49 return this._parse(this._value, context, "$value");
}
cin
working on IoC configuration
r114 _parse<S, V>(value: V, context: ActivationContext<S>, path: string): Parse<V> {
cin
changed the project structure
r49 if (isPrimitive(value))
cin
working on IoC configuration
r114 return value as any;
cin
changed the project structure
r49
if (isDescriptor(value))
return context.activate(value, path);
if (value instanceof Array)
cin
working on IoC configuration
r114 return value.map((x, i) => this._parse(x, context, `${path}[${i}]`)) as any;
cin
changed the project structure
r49
cin
working on IoC configuration
r114 const t: any = {};
for (const p in value)
cin
changed the project structure
r49 t[p] = this._parse(value[p], context, `${path}.${p}`);
return t;
}
toString() {
return "@walk";
}
}