本文整理匯總了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));
}