本文整理汇总了TypeScript中aurelia-dependency-injection.Container.makeGlobal方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Container.makeGlobal方法的具体用法?TypeScript Container.makeGlobal怎么用?TypeScript Container.makeGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aurelia-dependency-injection.Container
的用法示例。
在下文中一共展示了Container.makeGlobal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should do things on things", () => {
initialize();
// type '1', '2', 'left', 'left', 'v' should result in '12'
let inputElement = document.createElement("input");
let container = new Container();
container.makeGlobal();
container.registerInstance(Element, inputElement);
let engine = container.get(TemplatingEngine)
let mask = "(999) 999-9999";
let maskedInput = engine.createViewModelForUnitTest(MaskedInput, {
"mask": mask
});
maskedInput.isFocused = () => true;
maskedInput.isHidden = () => false;
maskedInput.value = "";
expect(maskedInput.mask).toBe(mask);
expect(maskedInput.value).toBe("");
expect(inputElement.value).toBe("");
expect(maskedInput.element).toBe(inputElement);
expect(maskedInput.getCaretPosition()).toBe(0);
maskedInput.attached();
expect(maskedInput.inputElement).toBe(inputElement);
expect(inputElement.value).toBe("(___) ___-____");
expect(maskedInput.caretPos).toBe(1);
expect(maskedInput.getCaretPosition()).toBe(1);
let focusEvent = null;
let inputEvent = null;
let keyupEvent = null;
focusEvent = makeFocusEvent();
maskedInput.onFocus(focusEvent);
expect(getCursor(inputElement)).toBe(1);
inputElement.value = "(1___) ___-____";
setCursor(inputElement, 2);
inputEvent = makeInputEvent();
maskedInput.onInput(inputEvent);
keyupEvent = makeKeyupEvent("1");
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(1__) ___-____");
expect(maskedInput.value).toBe("1");
expect(maskedInput.oldValue).toBe("(1__) ___-____");
expect(maskedInput.oldValueUnmasked).toBe("1");
expect(getCursor(inputElement)).toBe(2);
inputElement.value = "(12__) ___-____";
inputEvent = makeInputEvent();
maskedInput.onInput(inputEvent);
keyupEvent = makeKeyupEvent("2");
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(12_) ___-____");
expect(maskedInput.value).toBe("12");
expect(maskedInput.oldValue).toBe("(12_) ___-____");
expect(maskedInput.oldValueUnmasked).toBe("12");
expect(getCursor(inputElement)).toBe(3);
setCursor(inputElement, 2);
expect(inputElement.value).toBe("(12_) ___-____");
inputEvent = makeInputEvent();
maskedInput.onInput(inputEvent);
keyupEvent = makeKeyupEvent(LEFT);
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(12_) ___-____");
expect(maskedInput.value).toBe("12");
expect(maskedInput.oldValue).toBe("(12_) ___-____");
expect(maskedInput.oldValueUnmasked).toBe("12");
expect(getCursor(inputElement)).toBe(2);
setCursor(inputElement, 1);
expect(inputElement.value).toBe("(12_) ___-____");
maskedInput.onInput(inputEvent);
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(12_) ___-____");
expect(maskedInput.value).toBe("12");
expect(maskedInput.oldValue).toBe("(12_) ___-____");
expect(maskedInput.oldValueUnmasked).toBe("12");
expect(maskedInput.caretPos).toBe(1);
expect(getCursor(inputElement)).toBe(1);
inputElement.value = "(v12__) ___-____";
setCursor(inputElement, 2);
inputEvent = makeInputEvent();
maskedInput.onInput(inputEvent);
keyupEvent = makeKeyupEvent('v');
maskedInput.onKeyUp(keyupEvent);
expect(inputElement.value).toBe("(12_) ___-____");
expect(maskedInput.value).toBe("12");
expect(getCursor(inputElement)).toBe(2);
});
示例2: Container
import { Database } from './database/Database';
import * as errorHandlers from './middleware/errorHandlers';
import * as queryHandlers from './middleware/queryHandlers';
import * as requestHandlers from './middleware/requestHandlers';
import { ServiceManager } from './services/ServiceManager';
import './utils/ObjectExtensions'; // add object extension methods;
const env = process.env.NODE_ENV || 'dev';
const PUBLIC_DIRECTORY = 'www';
const PORT_KEY = 'port';
const DEFAULT_PORT = 443;
// set up the dependency injection container
const container: Container = new Container();
container.makeGlobal();
const appConfig: any = new AppConfig('./config.json');
container.registerInstance(AppConfig, appConfig);
/******* set up logging ********/
const logOptions = appConfig.logging;
logOptions.name = appConfig.name;
const log = new Logger(logOptions);
container.registerInstance(Logger, log);
/********* end set up logging ********/
let options: DbOptions = appConfig.database;