本文整理汇总了TypeScript中aurelia-dependency-injection.Container类的典型用法代码示例。如果您正苦于以下问题:TypeScript Container类的具体用法?TypeScript Container怎么用?TypeScript Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Container类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('ToDo', () => {
const container = new Container();
const httpClient = container.get(Rest);
const githubClient = container.get(Rest);
const dataServices = new DataServices(httpClient, githubClient);
let sut = new ToDo(dataServices);
describe('constructor()', () => {
it('dataServices should be defined', () => {
expect(sut.dataServices).toBeDefined();
});
});
describe('activate()', () => {
let todoItems = [
{ id: 1, description: 'I need to read PinpointTownes' }
];
it('todoItems exist', done => {
spyOn(dataServices, 'getToDoItems').and.callFake(() => {
return Promise.resolve(todoItems);
});
sut.activate()
.then(() => {
expect(sut.todoItems).toBe(todoItems);
done();
});
});
});
});
示例2: beforeEach
beforeEach(() => {
container = new Container();
container.registerInstance(Element, DOM.createElement("div"));
templatingEngine = container.get(TemplatingEngine);
sut = templatingEngine.createViewModelForUnitTest(ScrollSpyElement);
});
示例3: beforeEach
beforeEach(() => {
history = new MockHistory();
container = new Container();
container.registerSingleton(RouteLoader, MockLoader);
// tslint:disable-next-line
ea = { publish() { } } as any;
viewPort = {
process(viewPortInstruction: ViewPortInstruction) {
return Promise.resolve();
},
// tslint:disable-next-line
swap() { }
} as any;
// tslint:disable-next-line
instruction = { resolve() { } } as any;
provider = {
createPipeline() {
let p = new Pipeline();
p.addStep({ run(inst, next) { return pipelineStep(inst, next); } });
return p;
}
} as any;
router = new AppRouter(container, history, provider, ea);
});
示例4: beforeEach
beforeEach(() => {
container = new Container();
container.registerInstance(Element, DOM.createElement("div"));
templatingEngine = container.get(TemplatingEngine);
sut = templatingEngine.createViewModelForUnitTest(DropdownDividerAttribute);
});
开发者ID:eriklieben,项目名称:old-aurelia-materialize-css-before-rc1,代码行数:7,代码来源:dropdownDividerAttribute.spec.ts
示例5: beforeEach
beforeEach(() => {
container = new Container();
templatingEngine = container.get(TemplatingEngine);
sut = templatingEngine.createViewModelForUnitTest(ButtonElement);
sut.element = DOM.createElement("a");
});
示例6: it
it('should return null when the parent container is not present', () => {
var sut = new Parent("test"),
childContainer = new Container(),
instance = {};
childContainer.registerInstance("test", instance);
expect(sut.get(childContainer)).toBe(null);
});
示例7: get
public get(container: Container): any {
let dynamicDependencies = this.dynamicDependencies.length > 0 ?
this.dynamicDependencies.map(dependency => dependency["protocol:aurelia:resolver"] ?
dependency.get(container) : container.invoke(dependency)) : undefined;
const instance = container.invoke(this.key, dynamicDependencies);
container.registerInstance(this.asKey, instance);
return instance;
}
示例8: beforeAll
beforeAll(() => {
const container = new Container();
container.registerInstance(BindingLanguage, container.get(TemplatingBindingLanguage));
const messageParser = container.get(ValidationMessageParser);
const propertyParser = container.get(PropertyAccessorParser);
ValidationRules.initialize(messageParser, propertyParser);
validator = container.get(StandardValidator);
});
示例9: beforeAll
beforeAll(() => {
let container = new Container();
bindingEngine = container.get(BindingEngine);
let bindingBehaviors = {
updateTrigger: container.get(UpdateTriggerBindingBehavior)
};
lookupFunctions = { bindingBehaviors: name => bindingBehaviors[name] };
});
示例10: create
/**
* Creates a new controller instance.
*/
public create(validator?: Validator) {
if (!validator) {
validator = this.container.get(Validator) as Validator;
}
const propertyParser = this.container.get(PropertyAccessorParser) as PropertyAccessorParser;
return new ValidationController(validator, propertyParser);
}