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

TypeScript di.bind函数代码示例

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

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



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

示例1: createInjector

export function createInjector(zone: NgZone, bus: MessageBus): Injector {
  BrowserDomAdapter.makeCurrent();
  _rootBindings.push(bind(NgZone).toValue(zone));
  _rootBindings.push(bind(MessageBus).toValue(bus));
  var injector: Injector = Injector.resolveAndCreate(_rootBindings);
  return injector.resolveAndCreateChild(_injectorBindings());
}
开发者ID:chiragjraval,项目名称:AdvisroySystemPOC,代码行数:7,代码来源:di_bindings.ts


示例2: createBindings

 static createBindings(childTokens: any[]): Provider[] {
   return [
     bind(_CHILDREN).toFactory(
         (injector: Injector) => childTokens.map(token => injector.get(token)), [Injector]),
     bind(MultiReporter).toFactory(children => new MultiReporter(children), [_CHILDREN])
   ];
 }
开发者ID:LordBinary,项目名称:angular,代码行数:7,代码来源:multi_reporter.ts


示例3: bind

        .then((args) => {
          var capabilities = args[0];
          var userAgent = args[1];

          // This might still create instances twice. We are creating a new injector with all the
          // providers.
          // Only WebDriverAdapter is reused.
          // TODO vsavkin consider changing it when toAsyncFactory is added back or when child
          // injectors are handled better.
          var injector = Injector.resolveAndCreate([
            sampleBindings, bind(Options.CAPABILITIES).toValue(capabilities),
            bind(Options.USER_AGENT).toValue(userAgent),
            provide(WebDriverAdapter, {useValue: adapter})
          ]);

          var sampler = injector.get(Sampler);
          return sampler.sample();
        });
开发者ID:LordBinary,项目名称:angular,代码行数:18,代码来源:runner.ts


示例4: sample

  sample({id, execute, prepare, microMetrics, bindings}:
             {id: string, execute?: any, prepare?: any, microMetrics?: any, bindings?: any}):
      Promise<SampleState> {
    var sampleBindings = [
      _DEFAULT_PROVIDERS,
      this._defaultBindings,
      bind(Options.SAMPLE_ID).toValue(id),
      bind(Options.EXECUTE).toValue(execute)
    ];
    if (isPresent(prepare)) {
      sampleBindings.push(bind(Options.PREPARE).toValue(prepare));
    }
    if (isPresent(microMetrics)) {
      sampleBindings.push(bind(Options.MICRO_METRICS).toValue(microMetrics));
    }
    if (isPresent(bindings)) {
      sampleBindings.push(bindings);
    }

    var inj = Injector.resolveAndCreate(sampleBindings);
    var adapter = inj.get(WebDriverAdapter);

    return PromiseWrapper
        .all([adapter.capabilities(), adapter.executeScript('return window.navigator.userAgent;')])
        .then((args) => {
          var capabilities = args[0];
          var userAgent = args[1];

          // This might still create instances twice. We are creating a new injector with all the
          // providers.
          // Only WebDriverAdapter is reused.
          // TODO vsavkin consider changing it when toAsyncFactory is added back or when child
          // injectors are handled better.
          var injector = Injector.resolveAndCreate([
            sampleBindings,
            bind(Options.CAPABILITIES).toValue(capabilities),
            bind(Options.USER_AGENT).toValue(userAgent),
            provide(WebDriverAdapter, {useValue: adapter})
          ]);

          var sampler = injector.get(Sampler);
          return sampler.sample();
        });
  }
开发者ID:1186792881,项目名称:angular,代码行数:44,代码来源:runner.ts


示例5: _injectorBindings

// TODO: This code is nearly identical to core/application. There should be a way to only write it
// once
function _injectorBindings(): any[] {
  return [
    bind(DOCUMENT)
        .toValue(DOM.defaultDoc()),
    EventManager,
    new Binding(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}),
    new Binding(EVENT_MANAGER_PLUGINS, {toClass: KeyEventsPlugin, multi: true}),
    new Binding(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}),
    DomRenderer,
    bind(Renderer).toAlias(DomRenderer),
    APP_ID_RANDOM_BINDING,
    DomSharedStylesHost,
    bind(SharedStylesHost).toAlias(DomSharedStylesHost),
    Serializer,
    bind(ON_WEB_WORKER).toValue(false),
    bind(ElementSchemaRegistry).toValue(new DomElementSchemaRegistry()),
    RenderViewWithFragmentsStore,
    RenderProtoViewRefStore,
    AppViewPool,
    bind(APP_VIEW_POOL_CAPACITY).toValue(10000),
    AppViewManager,
    AppViewManagerUtils,
    AppViewListener,
    ProtoViewFactory,
    ViewResolver,
    DEFAULT_PIPES,
    DirectiveResolver,
    Parser,
    Lexer,
    bind(ExceptionHandler).toFactory(() => new ExceptionHandler(DOM), []),
    bind(XHR).toValue(new XHRImpl()),
    UrlResolver,
    DynamicComponentLoader,
    Testability,
    AnchorBasedAppRootUrl,
    bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl),
    WebWorkerApplication,
    WebWorkerSetup,
    MessageBasedXHRImpl,
    MessageBasedRenderer,
    ServiceMessageBrokerFactory,
    ClientMessageBrokerFactory,
    BrowserDetails,
    AnimationBuilder,
  ];
}
开发者ID:chiragjraval,项目名称:AdvisroySystemPOC,代码行数:48,代码来源:di_bindings.ts


示例6: bindTo

 static bindTo(childTokens: any[]): Provider[] {
   var res = [
     bind(_CHILDREN).toFactory(
         (injector: Injector) => childTokens.map(token => injector.get(token)), [Injector]),
     bind(WebDriverExtension)
         .toFactory(
             (children: WebDriverExtension[], capabilities) => {
               var delegate;
               children.forEach(extension => {
                 if (extension.supports(capabilities)) {
                   delegate = extension;
                 }
               });
               if (isBlank(delegate)) {
                 throw new BaseException('Could not find a delegate for given capabilities!');
               }
               return delegate;
             },
             [_CHILDREN, Options.CAPABILITIES])
   ];
   return res;
 }
开发者ID:LordBinary,项目名称:angular,代码行数:22,代码来源:web_driver_extension.ts


示例7: applicationDomBindings

export function applicationDomBindings(): Array<Type | Binding | any[]> {
  if (isBlank(DOM)) {
    throw "Must set a root DOM adapter first.";
  }
  return [
    bind(DOCUMENT)
        .toValue(DOM.defaultDoc()),
    EventManager,
    new Binding(EVENT_MANAGER_PLUGINS, {toClass: DomEventsPlugin, multi: true}),
    new Binding(EVENT_MANAGER_PLUGINS, {toClass: KeyEventsPlugin, multi: true}),
    new Binding(EVENT_MANAGER_PLUGINS, {toClass: HammerGesturesPlugin, multi: true}),
    DomRenderer,
    bind(Renderer).toAlias(DomRenderer),
    DomSharedStylesHost,
    bind(SharedStylesHost).toAlias(DomSharedStylesHost),
    EXCEPTION_BINDING,
    bind(XHR).toValue(new XHRImpl()),
    Testability,
    BrowserDetails,
    AnimationBuilder,
    FORM_BINDINGS
  ];
}
开发者ID:chiragjraval,项目名称:AdvisroySystemPOC,代码行数:23,代码来源:application_common.ts


示例8: compilerBindings

export function compilerBindings(): Array<Type | Binding | any[]> {
  return [
    Lexer,
    Parser,
    HtmlParser,
    TemplateParser,
    TemplateNormalizer,
    RuntimeMetadataResolver,
    StyleCompiler,
    CommandCompiler,
    ChangeDetectionCompiler,
    bind(ChangeDetectorGenConfig)
        .toValue(
            new ChangeDetectorGenConfig(assertionsEnabled(), assertionsEnabled(), false, true)),
    TemplateCompiler,
    RuntimeCompiler,
    bind(Compiler).toAlias(RuntimeCompiler),
    DomElementSchemaRegistry,
    bind(ElementSchemaRegistry).toAlias(DomElementSchemaRegistry),
    AnchorBasedAppRootUrl,
    bind(AppRootUrl).toAlias(AnchorBasedAppRootUrl),
    UrlResolver
  ];
}
开发者ID:chiragjraval,项目名称:AdvisroySystemPOC,代码行数:24,代码来源:compiler.ts


示例9: bindTo

 static bindTo(delegateToken): Provider[] {
   return [bind(Validator).toFactory((delegate) => delegate, [delegateToken])];
 }
开发者ID:hankduan,项目名称:angular,代码行数:3,代码来源:validator.ts


示例10: reportMeasureValues

    this._description = sampleDescription;
    this._path = path;
    this._writeFile = writeFile;
    this._now = now;
  }

  reportMeasureValues(measureValues: MeasureValues): Promise<any> {
    return PromiseWrapper.resolve(null);
  }

  reportSample(completeSample: MeasureValues[], validSample: MeasureValues[]): Promise<any> {
    var content = Json.stringify({
      'description': this._description,
      'completeSample': completeSample,
      'validSample': validSample
    });
    var filePath =
        `${this._path}/${this._description.id}_${DateWrapper.toMillis(this._now())}.json`;
    return this._writeFile(filePath, content);
  }
}

var _PATH = new OpaqueToken('JsonFileReporter.path');
var _PROVIDERS = [
  bind(JsonFileReporter)
      .toFactory((sampleDescription, path, writeFile, now) =>
                     new JsonFileReporter(sampleDescription, path, writeFile, now),
                 [SampleDescription, _PATH, Options.WRITE_FILE, Options.NOW]),
  provide(_PATH, {useValue: '.'})
];
开发者ID:hankduan,项目名称:angular,代码行数:30,代码来源:json_file_reporter.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript di.provide函数代码示例发布时间:2022-05-25
下一篇:
TypeScript debug_node.indexDebugNode函数代码示例发布时间: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