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


TypeScript IContainer.register方法代码示例

本文整理汇总了TypeScript中@aurelia/kernel.IContainer.register方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IContainer.register方法的具体用法?TypeScript IContainer.register怎么用?TypeScript IContainer.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在@aurelia/kernel.IContainer的用法示例。


在下文中一共展示了IContainer.register方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: registerAttribute

export function registerAttribute(this: ICustomAttributeType, container: IContainer): void {
  const description = this.description;
  const resourceKey = this.kind.keyFrom(description.name);
  const aliases = description.aliases;

  container.register(Registration.transient(resourceKey, this));

  for (let i = 0, ii = aliases.length; i < ii; ++i) {
    const aliasKey = this.kind.keyFrom(aliases[i]);
    container.register(Registration.alias(resourceKey, aliasKey));
  }
}
开发者ID:aurelia,项目名称:aurelia,代码行数:12,代码来源:custom-attribute.ts

示例2: 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;
  }
开发者ID:aurelia,项目名称:aurelia,代码行数:46,代码来源:aurelia.ts

示例3: registerElement

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

示例4: register

 public register(...params: (IRegistry | Record<string, Partial<IRegistry>>)[]): this {
   this.container.register(...params);
   return this;
 }
开发者ID:aurelia,项目名称:aurelia,代码行数:4,代码来源:aurelia.ts

示例5: 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

示例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.IContainer.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。