當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Kernel.bind方法代碼示例

本文整理匯總了TypeScript中inversify.Kernel.bind方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Kernel.bind方法的具體用法?TypeScript Kernel.bind怎麽用?TypeScript Kernel.bind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在inversify.Kernel的用法示例。


在下文中一共展示了Kernel.bind方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: registerUIElements

export function registerUIElements() {
    let output = vscode.window.createOutputChannel("Test Kitchen");
    kernel.bind<vscode.OutputChannel>("KitchenOutput").toConstantValue(output);

    let statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
    statusBarItem.command = "kitchen.terminateProcess";
    kernel.bind<vscode.StatusBarItem>("KitchenStatusBarItem").toConstantValue(statusBarItem);
}
開發者ID:jirkafajfr,項目名稱:vscode-kitchen,代碼行數:8,代碼來源:inversify.config.ts

示例2: it

    it("should call the configFn before the errorConfigFn", (done) => {
        let middleware = function(req: restify.Request, res: restify.Response, next: restify.Next) { return; };
        let configFn = sinon.spy((app: restify.Server) => { app.use(middleware); });
        let errorConfigFn = sinon.spy((app: restify.Server) => { app.use(middleware); });
        let kernel = new Kernel();

        @injectable()
        class TestController {}

        kernel.bind(TYPE.Controller).to(TestController);
        let server = new InversifyRestifyServer(kernel);

        server.setConfig(configFn)
            .setErrorConfig(errorConfigFn);

        expect(configFn.called).to.be.false;
        expect(errorConfigFn.called).to.be.false;

        server.build();

        expect(configFn.calledOnce).to.be.true;
        expect(errorConfigFn.calledOnce).to.be.true;
        expect(configFn.calledBefore(errorConfigFn)).to.be.true;
        done();
    });
開發者ID:hsyngkby,項目名稱:inversify-restify-utils,代碼行數:25,代碼來源:server.test.ts

示例3: 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();

        }));
開發者ID:takeshi,項目名稱:inversity-async-method-interceptor,代碼行數:15,代碼來源:async-method-interceptor.spec.ts

示例4: Kernel

':' //# http://sambal.org/?p=1014 ; exec `dirname $0`/../../node_modules/.bin/ts-node "$0" "$@"

/// <reference path="../../node_modules/inversify-dts/inversify/inversify.d.ts" />

console.log('hello')

// http://inversify.io/
import { Kernel, interfaces } from 'inversify'

interface IIntl {
	[k: string]: string
}

const kernel = new Kernel()

kernel
	.bind<IIntl>('intl')
	.toConstantValue({
		hello: 'bonjour'
	})
	.whenTargetTagged('lang', 'fr')
kernel
	.bind<IIntl>('intl')
	.toConstantValue({
		goodbye: 'au revoir'
	})
	.whenTargetTagged('lang', 'fr')
kernel
	.bind<IIntl>('intl')
	.toConstantValue({
		favorite_food: 'camembert'
	})
開發者ID:Offirmo,項目名稱:web-tech-experiments,代碼行數:32,代碼來源:index.ts

示例5: Kernel

/// <reference path="../node_modules/inversify-dts/inversify/inversify.d.ts" />
/// <reference path="../node_modules/reflect-metadata/reflect-metadata.d.ts" />

import "reflect-metadata";
import * as express from 'express';
import { Kernel } from 'inversify';
import { Server } from './framework/server';
import { FooController } from './controllers/foo-controller';
import { FooService } from './services/foo-service';

// set up kernel
var kernel = new Kernel();
kernel.bind<FooService>('FooService').to(FooService);
kernel.bind<FooController>('FooController').to(FooController);

// create server
var server = new Server(kernel);

server
    .build()
    .listen(3000, 'localhost', callback);

function callback() {
    console.log('listening on http://localhost:3000');
}
開發者ID:codyjs,項目名稱:express-typescript-ioc,代碼行數:25,代碼來源:app.ts

示例6: Kernel

import { Kernel, interfaces } from 'inversify';

import {Engine} from './engine';
import {V8Engine} from './v8-engine';
import {Vehicle} from './vehicle';
import {RearLeftWheel, RearRightWheel, FrontLeftWheel, FrontRightWheel} from './wheel';


var kernel = new Kernel();

kernel.bind<IVehicle>("vehicle").to(Vehicle);
kernel.bind<IEngine>("engine").to(V8Engine);


[RearLeftWheel, RearRightWheel, FrontLeftWheel, FrontRightWheel].forEach((constr: interfaces.Newable<IWheel>)=>{
	kernel.bind<IWheel>("wheels").to(constr);
});



export default kernel;
開發者ID:wasav,項目名稱:wasav-labs,代碼行數:21,代碼來源:dependencies-loader.ts

示例7: Kernel

import 'reflect-metadata';
import { interfaces, Controller, InversifyExpressServer, TYPE } from 'inversify-express-utils';
import { Kernel } from 'inversify';
import * as bodyParser from 'body-parser';
import TYPES from './constant/types';
import TAGS from './constant/tags';
import { HomeController } from './controller/home';
import { UserController } from './controller/user';
import { UserService } from './service/user';

// load everything needed to the kernel
let kernel = new Kernel();

kernel.bind<interfaces.Controller>(TYPE.Controller).to(HomeController).whenTargetNamed(TAGS.HomeController);
kernel.bind<interfaces.Controller>(TYPE.Controller).to(UserController).whenTargetNamed(TAGS.UserController);
kernel.bind<UserService>(TYPES.UserService).to(UserService);

// start the server
let server = new InversifyExpressServer(kernel);
server.setConfig((app) => {
  app.use(bodyParser.urlencoded({
    extended: true
  }));
  app.use(bodyParser.json());
});

let app = server.build();
app.listen(3000);
console.log('Server started on port 3000 :)');
開發者ID:codyjs,項目名稱:inversify-express-example,代碼行數:29,代碼來源:bootstrap.ts

示例8: Kernel

ďťżimport { Kernel, IKernel } from "inversify";
import {KernelStore} from "./KernelStore";

import { Ninja } from "./classes/Ninja";
import { Katana } from "./classes/katana";
import { Shuriken} from "./classes/shuriken";
import {Service} from "./classes/Service";

//import Page from "./Page";

let kernel = new Kernel();

//let kernel = KernelStore.get();
kernel.bind<INinja>("INinja").to(Ninja).inSingletonScope();
kernel.bind<IKatana>("IKatana").to(Katana);
kernel.bind<IShuriken>("IShuriken").to(Shuriken);
kernel.bind<IService>("IService").to(Service);
//kernel.bind<Page>(Page).to(Page).inSingletonScope();

export default kernel;
開發者ID:kongu-zz,項目名稱:inversify-react,代碼行數:20,代碼來源:inversify.config.ts

示例9:

import { Kernel } from 'inversify';

import { ArtilleryGateway } from './adaptor/gateway/loadTest';
import { ReadClientlogFS } from './adaptor/gateway/readClientlog';
import { ReadServerlogRequest, ReadServerlogFS } from './adaptor/gateway/readServerlog';
import { RunningRepositoryFS } from './adaptor/repository/runningRepository';
import { DefaultApp, AssignedApp } from './adaptor/gateway/externalApp';

import { MesureUsecase } from './domain/usecase/mesure';
import { OnlyAttackUsecase } from './domain/usecase/onlyAttack';
import {  SummaryUsecase } from './domain/usecase/summary';
import { ReadServerStatUsecase, ReadServerStatUsecaseI } from './domain/usecase/readServerStat';

import { LoadTestGateway } from './domain/interface/loadTest';
const kernel = new Kernel;

kernel.bind<ArtilleryGateway>(LoadTestGateway.interfaceName).to(ArtilleryGateway);
kernel.bind<ReadClientlogFS>("Clientlog").to(ReadClientlogFS);
kernel.bind<ReadServerlogRequest>("Serverlog").to(ReadServerlogRequest);
kernel.bind<ReadServerlogFS>("ServerlogLocal").to(ReadServerlogFS);
kernel.bind<AssignedApp>("ExternalApp").to(AssignedApp);

kernel.bind<RunningRepositoryFS>("RunningRepository").to(RunningRepositoryFS).inSingletonScope();

kernel.bind<ReadServerStatUsecase>("ReadServerStatUsecaseI").to(ReadServerStatUsecase);
kernel.bind<SummaryUsecase>("SummaryUsecaseI").to(SummaryUsecase)
kernel.bind<MesureUsecase>("MesureUsecaseI").to(MesureUsecase);
kernel.bind<OnlyAttackUsecase>("OnlyAttackUsecaseI").to(OnlyAttackUsecase);
export default kernel;
開發者ID:ryota0624,項目名稱:su,代碼行數:29,代碼來源:inversify.config.ts

示例10: Kernel

import { IBinding, Kernel } from "inversify";
import { ClientConfig } from "./Config/ClientConfig";

var kernel = new Kernel();

// bindings
kernel.bind<ClientConfig>("ClientConfig").to(ClientConfig).inSingletonScope();

export = kernel;
開發者ID:slice-beans,項目名稱:mmoge-type,代碼行數:9,代碼來源:inversify.config.ts


注:本文中的inversify.Kernel.bind方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。