本文整理汇总了TypeScript中@tsed/di.InjectorService.invoke方法的典型用法代码示例。如果您正苦于以下问题:TypeScript InjectorService.invoke方法的具体用法?TypeScript InjectorService.invoke怎么用?TypeScript InjectorService.invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@tsed/di.InjectorService
的用法示例。
在下文中一共展示了InjectorService.invoke方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createSettingsService
function createSettingsService(injector: InjectorService) {
const provider = GlobalProviders.get(ServerSettingsService)!;
const settingsService = injector.invoke<ServerSettingsService>(provider.useClass);
injector.forkProvider(ServerSettingsService, settingsService);
return settingsService;
}
示例2: getHandler
/**
*
*/
private getHandler(locals: Map<string | Function, any>): Function {
const {token, method} = this.handlerMetadata;
const provider = this.injector.getProvider(token);
/* istanbul ignore next */
if (!provider) {
throw new Error(`${nameOf(token)} component not found in the injector`);
}
let instance: any;
if (provider.scope !== ProviderScope.SINGLETON) {
instance = this.injector.invoke<any>(provider.useClass, locals, undefined, true);
locals.set(token, instance);
} else {
instance = this.injector.get<any>(token);
}
return instance[method!].bind(instance);
}