本文整理汇总了TypeScript中@aurelia/kernel.IContainer.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IContainer.get方法的具体用法?TypeScript IContainer.get怎么用?TypeScript IContainer.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@aurelia/kernel.IContainer
的用法示例。
在下文中一共展示了IContainer.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it(`should define the binding behavior`, function () {
expect(FooBindingBehavior['kind']).to.equal(BindingBehaviorResource);
expect(FooBindingBehavior['description'].name).to.equal('foo');
FooBindingBehavior['register'](container);
const instance = container.get(BindingBehaviorResource.keyFrom('foo'));
expect(instance).to.be.instanceof(FooBindingBehavior);
});
示例2: it
it(`should define the value converter`, function () {
expect(FooValueConverter['kind']).to.equal(ValueConverterResource);
expect(FooValueConverter['description'].name).to.equal('foo');
FooValueConverter['register'](container);
const instance = container.get(ValueConverterResource.keyFrom('foo'));
expect(instance).to.be.instanceof(FooValueConverter);
});
示例3: app
public app(config: ISinglePageApp): this {
const host = config.host as INode & {$au?: Aurelia | null};
const domInitializer = this.container.get(IDOMInitializer);
domInitializer.initialize(config);
Registration.instance(INode, host).register(this.container);
const startFlags = LifecycleFlags.fromStartTask | config.strategy;
const stopFlags = LifecycleFlags.fromStopTask | config.strategy;
let component: ICustomElement;
const componentOrType = config.component as ICustomElement | ICustomElementType;
if (CustomElementResource.isType(componentOrType as ICustomElementType)) {
this.container.register(componentOrType as ICustomElementType);
component = this.container.get<ICustomElement>(CustomElementResource.keyFrom((componentOrType as ICustomElementType).description.name));
} else {
component = componentOrType as ICustomElement;
}
component = ProxyObserver.getRawIfProxy(component);
const startTask = () => {
host.$au = this;
if (!this.components.includes(component)) {
this._root = component;
this.components.push(component);
component.$hydrate(startFlags, this.container as ExposedContext, host);
}
component.$bind(startFlags | LifecycleFlags.fromBind, null);
component.$attach(startFlags | LifecycleFlags.fromAttach);
};
this.startTasks.push(startTask);
this.stopTasks.push(() => {
component.$detach(stopFlags | LifecycleFlags.fromDetach);
component.$unbind(stopFlags | LifecycleFlags.fromUnbind);
host.$au = null;
});
if (this.isStarted) {
startTask();
}
return this;
}