• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript di.Key类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中angular2/di.Key的典型用法代码示例。如果您正苦于以下问题:TypeScript Key类的具体用法?TypeScript Key怎么用?TypeScript Key使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: constructor

 constructor() {
   this.viewId = Key.get(viewModule.View).id;
   this.ngElementId = Key.get(NgElement).id;
   this.viewContainerId = Key.get(ViewContainer).id;
   this.bindingPropagationConfigId = Key.get(BindingPropagationConfig).id;
   this.privateComponentLocationId = Key.get(pclModule.PrivateComponentLocation).id;
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:7,代码来源:element_injector.ts


示例2: directiveBinding

function directiveBinding({metadata}: {metadata?: any} = {}) {
  return new DirectiveBinding(Key.get("dummy"), null, [], [], [], metadata);
}
开发者ID:lavinjj,项目名称:angular,代码行数:3,代码来源:proto_view_factory_spec.ts


示例3: main

export function main() {
  BrowserDomAdapter.makeCurrent();
  var iterations = getIntParameter('iterations');

  // This benchmark does not use bootstrap and needs to create a reflector
  setupReflector();
  var bindings = [A, B, C, D, E];
  var injector = Injector.resolveAndCreate(bindings);

  var D_KEY = Key.get(D);
  var E_KEY = Key.get(E);
  var childInjector = injector.resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([])
                          .resolveAndCreateChild([]);

  var variousBindings = [A, bind(B).toClass(C), [D, [E]], bind(F).toValue(6)];

  var variousBindingsResolved = Injector.resolve(variousBindings);

  function getByToken() {
    for (var i = 0; i < iterations; ++i) {
      injector.get(D);
      injector.get(E);
    }
  }
  function getByKey() {
    for (var i = 0; i < iterations; ++i) {
      injector.get(D_KEY);
      injector.get(E_KEY);
    }
  }

  function getChild() {
    for (var i = 0; i < iterations; ++i) {
      childInjector.get(D);
      childInjector.get(E);
    }
  }

  function instantiate() {
    for (var i = 0; i < iterations; ++i) {
      var child = injector.resolveAndCreateChild([E]);
      child.get(E);
    }
  }

  /**
   * Creates an injector with a variety of binding types.
   */
  function createVariety() {
    for (var i = 0; i < iterations; ++i) {
      Injector.resolveAndCreate(variousBindings);
    }
  }

  /**
   * Same as [createVariety] but resolves bindings ahead of time.
   */
  function createVarietyResolved() {
    for (var i = 0; i < iterations; ++i) {
      Injector.fromResolvedBindings(variousBindingsResolved);
    }
  }

  bindAction('#getByToken', () => microBenchmark('injectAvg', iterations, getByToken));
  bindAction('#getByKey', () => microBenchmark('injectAvg', iterations, getByKey));
  bindAction('#getChild', () => microBenchmark('injectAvg', iterations, getChild));
  bindAction('#instantiate', () => microBenchmark('injectAvg', iterations, instantiate));
  bindAction('#createVariety', () => microBenchmark('injectAvg', iterations, createVariety));
  bindAction('#createVarietyResolved',
             () => microBenchmark('injectAvg', iterations, createVarietyResolved));
}
开发者ID:goderbauer,项目名称:angular,代码行数:74,代码来源:di_benchmark.ts


示例4: expect

 expect(() => Key.setMetadata(key, "meta2")).toThrowError();
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:1,代码来源:key_spec.ts


示例5: it

 it("should throw when assigning different metadata", function() {
   var key = registry.get('car');
   Key.setMetadata(key, "meta1");
   expect(() => Key.setMetadata(key, "meta2")).toThrowError();
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:5,代码来源:key_spec.ts


示例6: hasPreBuiltObject

 hasPreBuiltObject(type) {
   var pb = this._getPreBuiltObjectByKeyId(Key.get(type).id);
   return pb !== _undefined && isPresent(pb);
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:4,代码来源:element_injector.ts


示例7: hasDirective

 hasDirective(type) {
   return this._getDirectiveByKeyId(Key.get(type).id) !== _undefined;
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:3,代码来源:element_injector.ts


示例8: get

 get(token) {
   return this._getByKey(Key.get(token), 0, false, null);
 }
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:3,代码来源:element_injector.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript di.KeyRegistry类代码示例发布时间:2022-05-25
下一篇:
TypeScript di.Injector类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap