本文整理汇总了TypeScript中inversify.Container类的典型用法代码示例。如果您正苦于以下问题:TypeScript Container类的具体用法?TypeScript Container怎么用?TypeScript Container使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
container = new Container();
container
.bind<SettingsServiceAttributes>(registry.SettingsService)
.to(MockSettingsService)
.inSingletonScope();
container
.bind<interfaces.Factory<winston.LoggerInstance>>(registry.LoggerFactory)
.toFactory(loggerFactory);
});
示例2: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
container.rebind(Symbols.modules.fork).to(ForkModule);
block = createFakeBlock();
instance = container.get(Symbols.modules.fork);
loggerStub = container.get(Symbols.helpers.logger);
socketIOStub = container.get(Symbols.generic.socketIO);
forksModel = container.get(Symbols.models.forkStats);
});
示例3: it
it("Should be able to auto-wire binding declarations", () => {
let container = new Container();
// Note @inject annotations are required autoProvide
// even when using classes are used as identifiers
// See declaration of Warrior for more details
autoProvide(container, entites);
container.load(buildProviderModule());
let warrior = container.get(entites.Warrior);
expect(warrior.fight()).eql("Using Katana...");
});
示例4: beforeAll
beforeAll(() => {
const container = new Container();
const i18n = setupI18n();
i18n._ = (id: string) => id;
container.bind(TYPES.I18n).toConstantValue(i18n);
container.bind(NotificationServiceType).toConstantValue(mockNS);
loadNotifications(container);
notifications = container.get<UIUpdateNotifications>(
UIUpdateNotificationsType
);
});
示例5: beforeEach
beforeEach(() => {
delete process.env.NODE_ENV;
delete process.env.TEST_LOGGING;
delete process.env.LOG_LEVEL;
delete process.env.DATABASE_URL;
delete process.env.PORT;
container = new Container();
container
.bind<SettingsServiceAttributes>(registry.SettingsService)
.to(SettingsService);
});
示例6: beforeEach
beforeEach(() => {
container = createContainer();
container.bind(Symbols.api.utils.errorHandler).to(APIErrorHandler);
sandbox = sinon.createSandbox();
sendSpy = {send: sandbox.spy()};
response = {status: () => sendSpy, send: sendSpy.send };
responseStatusSpy = sandbox.spy(response, 'status');
request = {url: {startsWith: sandbox.stub().callsFake((start) => !(start === '/v2') ) }};
requestStub = request.url.startsWith;
next = sandbox.spy();
loggerStub = container.get(Symbols.helpers.logger);
instance = container.get(Symbols.api.utils.errorHandler);
});
示例7: Container
(async () => {
const port = 3000;
const container = new Container();
await container.loadAsync(bindings);
const app = new InversifyExpressServer(container);
const server = app.build();
server.listen(port, () => {
console.log(`Server running at http://127.0.0.1:${port}/`)
});
})();
示例8: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
loggerStub = container.get(Symbols.helpers.logger);
peerLogicStub = new PeerLogicStub();
systemModuleStub = container.get(Symbols.modules.system);
peersFactoryStub = sandbox.stub().returns(peerLogicStub);
instance = new PeersLogic();
(instance as any).config = container.get(Symbols.generic.appConfig);
(instance as any).logger = loggerStub;
(instance as any).peersFactory = peersFactoryStub;
(instance as any).systemModule = systemModuleStub;
});
示例9: beforeAll
beforeAll(async () => {
knex = Knex(DEFAULT_DB_CONFIG);
await knex.migrate.latest();
await knex.seed.run();
const dbConfig = new DbConfig(DEFAULT_DB_CONFIG);
container = new Container();
container.bind<DbConfig>('DefaultDbConfig').toConstantValue(dbConfig);
// container...
container.bind<ICounterRepository>(TYPES.ICounterRepository).to(CounterRepository);
});
示例10: beforeEach
beforeEach(() => {
container.rebind(Symbols.helpers.slots).to(Slots);
realSlots = container.get(Symbols.helpers.slots);
(inst as any).slots = {
getSlotNumber: realSlots.getSlotNumber,
interval: (realSlots as any).interval,
};
lastBlk = { timestamp: constants.blockTime };
blk = { timestamp: constants.blockTime * 2 };
});