當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript inversify.Container類代碼示例

本文整理匯總了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);
 });
開發者ID:patrickhousley,項目名稱:xyzzy-mean,代碼行數:10,代碼來源:logger.spec.ts

示例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);

  });
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:11,代碼來源:fork.spec.ts

示例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...");

    });
開發者ID:inversify,項目名稱:inversify-binding-decorators,代碼行數:12,代碼來源:auto_wire.test.ts

示例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
    );
  });
開發者ID:dcos,項目名稱:dcos-ui,代碼行數:12,代碼來源:notifications-test.ts

示例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);
  });
開發者ID:patrickhousley,項目名稱:xyzzy-mean,代碼行數:12,代碼來源:Settings.spec.ts

示例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);
 });
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:13,代碼來源:errorHandler.spec.ts

示例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}/`)
    });

})();
開發者ID:inversify,項目名稱:inversify-express-example,代碼行數:13,代碼來源:index.ts

示例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;
 });
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:13,代碼來源:peers.spec.ts

示例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);

    });
開發者ID:baotaizhang,項目名稱:fullstack-pro,代碼行數:14,代碼來源:counter-repository.test.ts

示例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 };
 });
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:10,代碼來源:verify.spec.ts


注:本文中的inversify.Container類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。