本文整理匯總了TypeScript中inversify.Kernel.load方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Kernel.load方法的具體用法?TypeScript Kernel.load怎麽用?TypeScript Kernel.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類inversify.Kernel
的用法示例。
在下文中一共展示了Kernel.load方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: require
/// <reference path="../../node_modules/inversify-dts/inversify/inversify.d.ts" />
import { Kernel, interfaces } from "inversify"
import * as Mod1 from './mod1/inversify'
const mod1_schema: JSON = require('./overrides/mod1_schema.json')
const default_kernel = new Kernel()
default_kernel.load(Mod1.kernel_module)
const kernel = new Kernel()
kernel.parent = default_kernel
kernel
.bind<Mod1.Schema>(Mod1.TYPES.Schema)
.toConstantValue(mod1_schema as Mod1.Schema)
kernel
.bind<Mod1.StaticData>(Mod1.TYPES.StaticData)
.toConstantValue([ { name: 'OV Mod1 foo'}] as Mod1.StaticData)
export default kernel
示例2: Kernel
import { Kernel } from 'inversify';
import * as morgan from 'morgan';
import * as bodyParser from 'body-parser';
import * as cors from 'cors';
import * as jwt from 'express-jwt';
import { commands, controllers, infra, queries } from './bootstrap';
import { config } from './config';
import { DonorsFeed } from './donors-feed';
import { TYPES } from './lib/types';
import * as http from 'http';
let kernel = new Kernel();
kernel.load(infra, commands, queries, controllers);
let server = new InversifyExpressServer(kernel);
let httpServer = http.createServer();
server.setConfig((app) => {
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(morgan('combined'));
app.use(cors({
origin: (origin, callback) => {
try {
let ok: boolean = config.originsWhitelist.indexOf(origin) !== -1
callback(null, ok);
示例3: Kernel
import { Kernel } from 'inversify';
import { diModule } from 'retax-di';
const kernel = new Kernel();
kernel.load(diModule);
export default kernel;
示例4: createKernel
export function createKernel(option?: KernelOption) {
let kernel = new i.Kernel();
kernel.load(CoreModules);
return new Kernel(kernel);
}