當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。