Tag: 反向控制

Inversify:与类名称的上下文注入

我正在尝试使用inversify将注入器注入到不同的类中。 我想将目标类名称传递给logging器对其进行分类。 问题是我无法从创build绑定的位置访问目标名称: container.bind<log4js.Logger>(Types.Logger).toDynamicValue(context => { let className = context….?; // Finds class name return log4js.getLogger(className); }); 除了在接收logging器的对象中创buildlogging器之后设置logging器之外,还有其他方法吗? 谢谢! 安托万

如何注入一个asynchronous依赖inversify?

我有TypeScript应用程序,我正在使用Inversify for IoC。 我有一个连接类: 'use strict'; import { injectable } from 'inversify'; import { createConnection, Connection } from "typeorm"; import { Photo, PhotoMetadata, Author, Album } from '../index'; @injectable() class DBConnectionManager { public createPGConnection(): Promise<Connection> { return createConnection({ driver: { type: "postgres", host: "host", port: 5432, username: "username", password: "password", database: "username" }, entities: [ […]