Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 12x 12x 12x 45x 45x 59x 59x 59x 59x 3x 59x 4x 3x 58x | import { IInitializer } from "./IInitializer"; import { Keys } from "../../Keys"; import { ArgResolver } from "../../definitions/helpers/ArgResolver"; import { IResolver } from "../../interfaces/IResolver"; export class InjectPropertiesInitializer implements IInitializer { argResolver: ArgResolver = new ArgResolver(this.resolver); constructor(readonly resolver: IResolver) { } async run(resolvedInstance: any, definition: any): Promise<any> { return this.injectProperties(resolvedInstance, definition); } async injectProperties(resolvedInstance: any, definition: any): Promise<any> { const propertiesMeta = Reflect.getMetadata(Keys.PROPERTY_INJECT_KEY, definition.content) || {}; Iif (!propertiesMeta) return resolvedInstance; const setInstanceProperty = (key: any, value: any) => { resolvedInstance[key] = value; }; for (const key in propertiesMeta) { const resolvedKey = typeof propertiesMeta[key] === "string" ? await this.resolver.resolve( propertiesMeta[key]) : await this.resolver.resolveByType( propertiesMeta[key]); setInstanceProperty(key, resolvedKey); } return resolvedInstance; } } |