当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript InjectorService.invoke方法代码示例

本文整理汇总了TypeScript中@tsed/common.InjectorService.invoke方法的典型用法代码示例。如果您正苦于以下问题:TypeScript InjectorService.invoke方法的具体用法?TypeScript InjectorService.invoke怎么用?TypeScript InjectorService.invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@tsed/common.InjectorService的用法示例。


在下文中一共展示了InjectorService.invoke方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: inject

    await inject([InjectorService], (injector: InjectorService) => {
      this.locals = new Map<string | Function, any>();
      const provider = injector.getProvider(ProductsCtrl)!;
      const target = provider.useClass;

      this.rebuildHandler = provider.scope !== ProviderScope.SINGLETON;

      this.instance = injector.invoke(target, this.locals, undefined, true);
    })();
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:9,代码来源:di.spec.ts

示例2: before

    before(inject([InjectorService], (injectorService: InjectorService) => {
      this.memoryStorage = {
        set: () => {
        },
        get: () => {

        }
      };

      const locals = new Map<any, any>();
      locals.set(MemoryStorage, this.memoryStorage);

      this.calendarsService = injectorService.invoke<CalendarsService>(CalendarsService, locals);
    }));
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:14,代码来源:CalendarsService.spec.ts

示例3: it

    it("should do something", inject([InjectorService], (injector: InjectorService) => {
      // create locals map
      const locals = new Map<any, any>();

      // replace DbService by a faker
      locals.set(DbService, {
        getData: () => {
          return "test";
        }
      });

      // give the locals map to the invoke method
      const instance: MyCtrl = injector.invoke<MyCtrl>(MyCtrl, locals);

      // and test it
      expect(!!instance).to.be.true;
      expect(instance.getData()).to.equals("test");
    }));
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:18,代码来源:testing-example.spec.ts

示例4: inject

 inject([InjectorService], (injectorService: InjectorService) => {
   instance = injectorService.invoke(CalendarCtrl);
 })
开发者ID:Romakita,项目名称:ts-express-decorators,代码行数:3,代码来源:testing-example.spec.ts


注:本文中的@tsed/common.InjectorService.invoke方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。