本文整理匯總了TypeScript中@tsed/common.InjectorService.getProvider方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript InjectorService.getProvider方法的具體用法?TypeScript InjectorService.getProvider怎麽用?TypeScript InjectorService.getProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@tsed/common.InjectorService
的用法示例。
在下文中一共展示了InjectorService.getProvider方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
})();
示例2: bindMiddleware
/**
*
* @param target
* @param scope
* @param promise
* @returns {(args: any[]) => Promise<any[]>}
*/
private bindMiddleware(target: any, scope: any, promise: Promise<any>): Promise<any> {
const provider = this.injector.getProvider(target);
if (provider) {
const instance = provider.instance;
const handlerMetadata: ISocketProviderMetadata = Store.from(instance).get("socketIO");
if (handlerMetadata.type === SocketProviderTypes.MIDDLEWARE) {
if (handlerMetadata.error) {
return promise.catch((error: any) => this.invoke(instance, handlerMetadata.handlers.use, {error, ...scope}));
}
return promise
.then(() => this.invoke(instance, handlerMetadata.handlers.use, scope))
.then((result: any) => {
if (result) {
scope.args = [].concat(result);
}
});
}
}
return promise;
}