当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Registration.singleton方法代码示例

本文整理汇总了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 };
}
开发者ID:aurelia,项目名称:aurelia,代码行数:40,代码来源:template-controller-tests.ts

示例2: register

 class Bar {public static register(container2: IContainer) { container2.register(Registration.singleton(Bar, Bar)); }}
开发者ID:aurelia,项目名称:aurelia,代码行数:1,代码来源:template.spec.ts

示例3: register

 public static register(container: IContainer): IResolver<IProjectorLocator> {
   return Registration.singleton(IProjectorLocator, this).register(container);
 }
开发者ID:aurelia,项目名称:aurelia,代码行数:3,代码来源:projectors.ts

示例4: register

function register(this: IBindingBehaviorType, container: IContainer): void {
  const resourceKey = BindingBehaviorResource.keyFrom(this.description.name);
  container.register(Registration.singleton(resourceKey, this));
}
开发者ID:aurelia,项目名称:aurelia,代码行数:4,代码来源:binding-behavior.ts

示例5: register

 target.register = function register(container: IContainer): IResolver {
   return Registration.singleton(IAttributePattern, target).register(container, IAttributePattern);
 };
开发者ID:aurelia,项目名称:aurelia,代码行数:3,代码来源:attribute-pattern.ts

示例6: register

function register(this: IValueConverterType, container: IContainer): void {
  const resourceKey = this.kind.keyFrom(this.description.name);
  container.register(Registration.singleton(resourceKey, this));
}
开发者ID:aurelia,项目名称:aurelia,代码行数:4,代码来源:value-converter.ts


注:本文中的@aurelia/kernel.Registration.singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。