本文整理汇总了TypeScript中@aurelia/kernel.Registration.singleton方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Registration.singleton方法的具体用法?TypeScript Registration.singleton怎么用?TypeScript Registration.singleton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@aurelia/kernel.Registration
的用法示例。
在下文中一共展示了Registration.singleton方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: InstanceProvider
export function hydrateCustomAttribute<T extends ICustomAttributeType>(
Type: T,
options: IAttributeTestOptions = {}
) : ICustomAttributeCreation<T> {
const AttributeType: ICustomAttributeType<AuNode> = Type as any;
const container = options.container || AuDOMConfiguration.createContainer();
const dom = container.get(IDOM);
if (options.lifecycle) {
Registration.instance(ILifecycle, options.lifecycle).register(container, ILifecycle);
}
const lifecycle = container.get(ILifecycle) as Lifecycle;
let location: IRenderLocation<AuNode> & AuNode = null;
container.register(AttributeType);
if (AttributeType.description.isTemplateController) {
const loc = AuNode.createRenderLocation();
AuNode.createHost().appendChild(loc.$start).appendChild(loc);
container.register(
Registration.instance(
IRenderLocation,
location = (options.target as typeof loc) || loc
),
Registration.singleton(IViewFactory, FakeViewFactory)
);
} else {
const hostProvider = new InstanceProvider();
hostProvider.prepare(options.target || AuNode.createHost());
dom.registerElementResolver(container, hostProvider);
}
const attribute = container.get<InstanceType<T> & ICustomAttribute<AuNode>>(
CustomAttributeResource.keyFrom(AttributeType.description.name)
);
attribute.$hydrate(LF.none, container);
return { attribute: attribute as Overwrite<InstanceType<T>, ICustomAttribute<AuNode>>, location, lifecycle };
}
示例2: register
class Bar {public static register(container2: IContainer) { container2.register(Registration.singleton(Bar, Bar)); }}
示例3: register
public static register(container: IContainer): IResolver<IProjectorLocator> {
return Registration.singleton(IProjectorLocator, this).register(container);
}
示例4: register
function register(this: IBindingBehaviorType, container: IContainer): void {
const resourceKey = BindingBehaviorResource.keyFrom(this.description.name);
container.register(Registration.singleton(resourceKey, this));
}
示例5: register
target.register = function register(container: IContainer): IResolver {
return Registration.singleton(IAttributePattern, target).register(container, IAttributePattern);
};
示例6: register
function register(this: IValueConverterType, container: IContainer): void {
const resourceKey = this.kind.keyFrom(this.description.name);
container.register(Registration.singleton(resourceKey, this));
}