本文整理匯總了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 };
});