本文整理汇总了TypeScript中aurelia-dependency-injection.Container.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Container.get方法的具体用法?TypeScript Container.get怎么用?TypeScript Container.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aurelia-dependency-injection.Container
的用法示例。
在下文中一共展示了Container.get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(done => {
let container = new Container();
viewSlot = new ViewSlotMock();
viewFactory = new BoundViewFactoryMock();
observerLocator = container.get(ObserverLocator);
repeatStrategyLocator = container.get(RepeatStrategyLocator);
repeatStrategyMock = new RepeatStrategyMock();
container.registerInstance(TargetInstruction, instructionMock);
container.registerInstance(ViewResources, viewResourcesMock);
container.registerInstance(ViewSlot, viewSlot);
container.registerInstance(BoundViewFactory, viewFactory);
component = StageComponent.withResources().inView('<div repeat.for="item of items"></div>').boundTo({ items: [] });
component.create(bootstrap).then(() => {
repeat = component.viewModel;
repeat.viewSlot = viewSlot;
repeat.instruction = instructionMock;
repeat.viewFactory = viewFactory;
repeat.observerLocator = observerLocator;
repeat.strategyLocator = repeatStrategyLocator;
done();
});
});
示例2: 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);
}
示例3: 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();
});
});
});
});
示例4: beforeAll
beforeAll(() => {
let container = new Container();
bindingEngine = container.get(BindingEngine);
let bindingBehaviors = {
updateTrigger: container.get(UpdateTriggerBindingBehavior)
};
lookupFunctions = { bindingBehaviors: name => bindingBehaviors[name] };
});
示例5: 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);
});
示例6: it
it('should not modify the default settings', async done => {
const overrideSettings = { model: 'model data' };
const expectedSettings = Object.assign({}, container.get(DefaultDialogSettings));
await _success(() => dialogService.open(overrideSettings), done);
// clone again the default settings, jasmine doesn't like them being a class
const actualSettings = Object.assign({}, container.get(DefaultDialogSettings));
expect(actualSettings).toEqual(expectedSettings);
done();
});
示例7: describe
describe('DataServices', () => {
const container = new Container();
const httpClient = container.get(Rest);
const githubClient = container.get(Rest);
let sut = new DataServices(httpClient, githubClient);
describe('constructor()', () => {
it('should have a resourceClient defined', () => {
expect(sut.resourcesClient).toBeDefined();
});
it('should have logger defined with Data Services as id', () => {
expect(sut.logger).toBeDefined();
expect(sut.logger.id).toBe('Data Services');
});
it('should have a githubClient defined', () => {
expect(sut.githubClient).toBeDefined();
});
});
describe('getToDoItems()', () => {
it('returns items for only authenticated user', done => {
let todoItems = [
{ id: 1, description: 'I need to read PinpointTownes' }
];
spyOn(httpClient, 'find').and.callFake((endPoint) => {
if (endPoint === 'todoItems') {
return Promise.resolve(todoItems);
}
});
sut.getToDoItems().then(response => {
expect(response).toBe(todoItems);
done();
});
});
});
describe('getUsers', () => {
it('returns users', done => {
let users = [
{ userId: 1, userName: 'John Doe' }
];
spyOn(githubClient, 'find').and.callFake((endPoint) => {
if (endPoint === 'users') {
return Promise.resolve(users);
}
});
sut.getUsers().then(response => {
expect(response).toBe(users);
done();
});
});
});
});
示例8: beforeAll
beforeAll(() => {
const container = new Container();
bindingEngine = container.get(BindingEngine);
const bindingBehaviors = {
attr: container.get(AttrBindingBehavior)
};
const valueConverters = {};
lookupFunctions = {
bindingBehaviors: name => bindingBehaviors[name],
valueConverters: name => valueConverters[name]
};
});
示例9: configure
export function configure(frameworkConfiguration: FrameworkConfiguration, pluginConfiguration: Function) {
let container: Container = frameworkConfiguration.container;
let storage: LocalStorage = container.get(LocalStorage);
let securityContext: SecurityContext = container.get(SecurityContext);
if (pluginConfiguration) {
pluginConfiguration(securityContext);
}
return securityContext.authenticate(new ImplicitCredential()).then(null, failure => {
return storage.get<string>(securityContext.configuration.authorizationTokenStorageKey).then(token => {
return securityContext.authenticate(new TokenCredential(token));
}).then(null, tokenNotValid => securityContext.deleteAndRevokeToken());
}).then(null, failure => console.debug(failure));
}
示例10: beforeEach
beforeEach(() => {
container = new Container();
container.registerInstance(Element, DOM.createElement("div"));
templatingEngine = container.get(TemplatingEngine);
sut = templatingEngine.createViewModelForUnitTest(ScrollSpyElement);
});