本文整理汇总了TypeScript中inversify.Kernel.applyMiddleware方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Kernel.applyMiddleware方法的具体用法?TypeScript Kernel.applyMiddleware怎么用?TypeScript Kernel.applyMiddleware使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inversify.Kernel
的用法示例。
在下文中一共展示了Kernel.applyMiddleware方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: testZone
testZone(async () => {
const kernel = new inversify.Kernel();
kernel.bind(TestService).to(TestService);
kernel.applyMiddleware(
interceptor.methodInterceptorMiddleware(kernel, {
targetClass: /TestService/
}, TestInterceptor)
);
const testService = kernel.get(TestService);
interceptorCall = false;
await testService.invoke();
expect(interceptorCall).toBeTruthy();
}));
示例2: Kernel
/// <reference path="../interfaces.d.ts" />
import "reflect-metadata";
import { Kernel } from "inversify";
import { makeProvideDecorator, makeFluentProvideDecorator } from "inversify-binding-decorators";
import makeLoggerMiddleware from "inversify-logger-middleware";
let kernel = new Kernel();
let logger = makeLoggerMiddleware();
kernel.applyMiddleware(logger);
let provide = makeProvideDecorator(kernel);
let fluentProvide = makeFluentProvideDecorator(kernel);
function provideNamed(serviceIdentifier: string, named: string) {
return fluentProvide(serviceIdentifier).whenTargetNamed(named).done();
}
export { kernel, provide, fluentProvide, provideNamed };