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

TypeScript di.bind函数代码示例

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

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



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

示例1: 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:0xJoKe,项目名称:angular,代码行数:8,代码来源:multi_reporter.ts


示例2: 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:0xJoKe,项目名称:angular,代码行数:23,代码来源:web_driver_extension.ts


示例3: SampleState

    var validSample = this._validator.validate(completeSample);
    var resultPromise = this._reporter.reportMeasureValues(measureValues);
    if (isPresent(validSample)) {
      resultPromise =
          resultPromise.then((_) => this._reporter.reportSample(completeSample, validSample))
    }
    return resultPromise.then((_) => new SampleState(completeSample, validSample));
  }
}

export class SampleState {
  constructor(public completeSample: any[], public validSample: any[]) {}
}

var _PROVIDERS = [
  bind(Sampler)
      .toFactory((driver, metric, reporter, validator, prepare, execute, now) => new Sampler({
                   driver: driver,
                   reporter: reporter,
                   validator: validator,
                   metric: metric,
                   // TODO(tbosch): DI right now does not support null/undefined objects
                   // Mostly because the cache would have to be initialized with a
                   // special null object, which is expensive.
                   prepare: prepare !== false ? prepare : null,
                   execute: execute,
                   now: now
                 }),
                 [
                   WebDriverAdapter,
                   Metric,
开发者ID:0xJoKe,项目名称:angular,代码行数:31,代码来源:sampler.ts


示例4: _markName

  _markName(index) { return `${_MARK_NAME_PREFIX}${index}`; }
}

var _MICRO_ITERATIONS_REGEX = /(.+)\*(\d+)$/g;

var _MAX_RETRY_COUNT = 20;
var _MARK_NAME_PREFIX = 'benchpress';
var _SET_TIMEOUT = new OpaqueToken('PerflogMetric.setTimeout');

var _MARK_NAME_FRAME_CAPUTRE = 'frameCapture';
// using 17ms as a somewhat looser threshold, instead of 16.6666ms
var _FRAME_TIME_SMOOTH_THRESHOLD = 17;

var _PROVIDERS = [
  bind(PerflogMetric)
      .toFactory(
          (driverExtension, setTimeout, microMetrics, forceGc, captureFrames, receivedData,
           requestCount) => new PerflogMetric(driverExtension, setTimeout, microMetrics, forceGc,
                                              captureFrames, receivedData, requestCount),
          [
            WebDriverExtension,
            _SET_TIMEOUT,
            Options.MICRO_METRICS,
            Options.FORCE_GC,
            Options.CAPTURE_FRAMES,
            Options.RECEIVED_DATA,
            Options.REQUEST_COUNT
          ]),
  provide(_SET_TIMEOUT, {useValue: (fn, millis) => TimerWrapper.setTimeout(fn, millis)})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:perflog_metric.ts


示例5: createStartEvent

    // The ios protocol does not support the notions of multiple processes in
    // the perflog...
    'pid': 'pid0'
  };
  if (isPresent(args)) {
    result['args'] = args;
  }
  return result;
}

function createStartEvent(name, time, args = null) {
  return createEvent('B', name, time, args);
}

function createEndEvent(name, time, args = null) {
  return createEvent('E', name, time, args);
}

function createMarkStartEvent(name, time) {
  return createEvent('b', name, time);
}

function createMarkEndEvent(name, time) {
  return createEvent('e', name, time);
}

var _PROVIDERS = [
  bind(IOsDriverExtension)
      .toFactory((driver) => new IOsDriverExtension(driver), [WebDriverAdapter])
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:ios_driver_extension.ts


示例6: bindTo

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


示例7: _printStringRow

    this._printStringRow(this._metricNames.map(metricName => {
      var samples = validSamples.map(measureValues => measureValues.values[metricName]);
      var mean = Statistic.calculateMean(samples);
      var cv = Statistic.calculateCoefficientOfVariation(samples, mean);
      var formattedMean = ConsoleReporter._formatNum(mean)
                              // Note: Don't use the unicode character for +- as it might cause
                              // hickups for consoles...
                              return NumberWrapper.isNaN(cv) ?
                              formattedMean :
                              `${formattedMean}+-${Math.floor(cv)}%`;
    }));
    return PromiseWrapper.resolve(null);
  }

  _printStringRow(parts: any[], fill = ' ') {
    this._print(
        parts.map(part => ConsoleReporter._lpad(part, this._columnWidth, fill)).join(' | '));
  }
}

var _PRINT = new OpaqueToken('ConsoleReporter.print');
var _COLUMN_WIDTH = new OpaqueToken('ConsoleReporter.columnWidth');
var _PROVIDERS = [
  bind(ConsoleReporter)
      .toFactory((columnWidth, sampleDescription, print) =>
                     new ConsoleReporter(columnWidth, sampleDescription, print),
                 [_COLUMN_WIDTH, SampleDescription, _PRINT]),
  provide(_COLUMN_WIDTH, {useValue: 18}),
  provide(_PRINT, {useValue: print})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:console_reporter.ts


示例8: PROVIDERS

  static get PROVIDERS(): Provider[] { return _PROVIDERS; }
  description: {[key: string]: any};

  constructor(public id: string, descriptions: Array<{[key: string]: any}>,
              public metrics: {[key: string]: any}) {
    this.description = {};
    descriptions.forEach(description => {
      StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value);
    });
  }

  toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; }
}

var _PROVIDERS = [
  bind(SampleDescription)
      .toFactory((metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
                     new SampleDescription(id,
                                           [
                                             {'forceGc': forceGc, 'userAgent': userAgent},
                                             validator.describe(),
                                             defaultDesc,
                                             userDesc
                                           ],
                                           metric.describe()),
                 [
                   Metric,
                   Options.SAMPLE_ID,
                   Options.FORCE_GC,
                   Options.USER_AGENT,
                   Validator,
开发者ID:0xJoKe,项目名称:angular,代码行数:31,代码来源:sample_description.ts


示例9: validate

  validate(completeSample: MeasureValues[]): MeasureValues[] {
    if (completeSample.length >= this._sampleSize) {
      var latestSample = ListWrapper.slice(completeSample, completeSample.length - this._sampleSize,
                                           completeSample.length);
      var xValues = [];
      var yValues = [];
      for (var i = 0; i < latestSample.length; i++) {
        // For now, we only use the array index as x value.
        // TODO(tbosch): think about whether we should use time here instead
        xValues.push(i);
        yValues.push(latestSample[i].values[this._metric]);
      }
      var regressionSlope = Statistic.calculateRegressionSlope(
          xValues, Statistic.calculateMean(xValues), yValues, Statistic.calculateMean(yValues));
      return regressionSlope >= 0 ? latestSample : null;
    } else {
      return null;
    }
  }
}

var _SAMPLE_SIZE = new OpaqueToken('RegressionSlopeValidator.sampleSize');
var _METRIC = new OpaqueToken('RegressionSlopeValidator.metric');
var _PROVIDERS = [
  bind(RegressionSlopeValidator)
      .toFactory((sampleSize, metric) => new RegressionSlopeValidator(sampleSize, metric),
                 [_SAMPLE_SIZE, _METRIC]),
  provide(_SAMPLE_SIZE, {useValue: 10}),
  provide(_METRIC, {useValue: 'scriptTime'})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:regression_slope_validator.ts


示例10: CAPTURE_FRAMES

  static get CAPTURE_FRAMES() { return _CAPTURE_FRAMES; }
}

var _SAMPLE_ID = new OpaqueToken('Options.sampleId');
var _DEFAULT_DESCRIPTION = new OpaqueToken('Options.defaultDescription');
var _SAMPLE_DESCRIPTION = new OpaqueToken('Options.sampleDescription');
var _FORCE_GC = new OpaqueToken('Options.forceGc');
var _PREPARE = new OpaqueToken('Options.prepare');
var _EXECUTE = new OpaqueToken('Options.execute');
var _CAPABILITIES = new OpaqueToken('Options.capabilities');
var _USER_AGENT = new OpaqueToken('Options.userAgent');
var _MICRO_METRICS = new OpaqueToken('Options.microMetrics');
var _NOW = new OpaqueToken('Options.now');
var _WRITE_FILE = new OpaqueToken('Options.writeFile');
var _RECEIVED_DATA = new OpaqueToken('Options.receivedData');
var _REQUEST_COUNT = new OpaqueToken('Options.requestCount');
var _CAPTURE_FRAMES = new OpaqueToken('Options.frameCapture');

var _DEFAULT_PROVIDERS = [
  bind(_DEFAULT_DESCRIPTION)
      .toValue({}),
  provide(_SAMPLE_DESCRIPTION, {useValue: {}}),
  provide(_FORCE_GC, {useValue: false}),
  provide(_PREPARE, {useValue: false}),
  provide(_MICRO_METRICS, {useValue: {}}),
  provide(_NOW, {useValue: () => DateWrapper.now()}),
  provide(_RECEIVED_DATA, {useValue: false}),
  provide(_REQUEST_COUNT, {useValue: false}),
  provide(_CAPTURE_FRAMES, {useValue: false})
];
开发者ID:0xJoKe,项目名称:angular,代码行数:30,代码来源:common_options.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript di.provide函数代码示例发布时间:2022-05-28
下一篇:
TypeScript debug_node.DebugElement类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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