當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript kernel.IContainer類代碼示例

本文整理匯總了TypeScript中@aurelia/kernel.IContainer的典型用法代碼示例。如果您正苦於以下問題:TypeScript IContainer類的具體用法?TypeScript IContainer怎麽用?TypeScript IContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IContainer類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: describe

describe(`@bindingBehavior('foo')`, function () {
  let container: IContainer;

  beforeEach(function () {
    container = DI.createContainer();
  });

  // @ts-ignore
  @bindingBehavior('foo')
  class FooBindingBehavior { }

  it(`should define the binding behavior`, function () {
    expect(FooBindingBehavior['kind']).to.equal(BindingBehaviorResource);
    expect(FooBindingBehavior['description'].name).to.equal('foo');
    FooBindingBehavior['register'](container);
    const instance = container.get(BindingBehaviorResource.keyFrom('foo'));
    expect(instance).to.be.instanceof(FooBindingBehavior);
  });

});
開發者ID:aurelia,項目名稱:aurelia,代碼行數:20,代碼來源:binding-behavior.spec.ts

示例3: register

export function register(container: IContainer): void {
  container.registerTransformer(ISVGAnalyzer, analyzer => {
    return {
      ...analyzer,
      isStandardSvgAttribute(node: INode, attributeName: string): boolean {
        // Using very HTML-specific code here since you won't install this module
        // unless you are actually running in a browser, using HTML,
        // and dealing with browser inconsistencies.

        if (!(node instanceof SVGElement)) {
          return false;
        }

        const nodeName = node.nodeName;

        return svgPresentationElements[nodeName] !== undefined && svgPresentationAttributes[attributeName] !== undefined
          || svgElements[nodeName] !== undefined && svgElements[nodeName].indexOf(attributeName) !== -1;
      }
    };
  });
}
開發者ID:aurelia,項目名稱:aurelia,代碼行數:21,代碼來源:svg-analyzer.ts

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

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

示例7: it

 it(`should define the binding behavior`, function () {
   expect(FooBindingBehavior['kind']).to.equal(BindingBehaviorResource);
   expect(FooBindingBehavior['description'].name).to.equal('foo');
   FooBindingBehavior['register'](container);
   const instance = container.get(BindingBehaviorResource.keyFrom('foo'));
   expect(instance).to.be.instanceof(FooBindingBehavior);
 });
開發者ID:aurelia,項目名稱:aurelia,代碼行數:7,代碼來源:binding-behavior.spec.ts

示例8: it

 it(`should define the value converter`, function () {
   expect(FooValueConverter['kind']).to.equal(ValueConverterResource);
   expect(FooValueConverter['description'].name).to.equal('foo');
   FooValueConverter['register'](container);
   const instance = container.get(ValueConverterResource.keyFrom('foo'));
   expect(instance).to.be.instanceof(FooValueConverter);
 });
開發者ID:aurelia,項目名稱:aurelia,代碼行數:7,代碼來源:value-converter.spec.ts

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

示例10: register

 public register(...params: (IRegistry | Record<string, Partial<IRegistry>>)[]): this {
   this.container.register(...params);
   return this;
 }
開發者ID:aurelia,項目名稱:aurelia,代碼行數:4,代碼來源:aurelia.ts


注:本文中的@aurelia/kernel.IContainer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。