Files
Angular-Docs-Cn/modules/benchpress/src/sample_description.ts
T
Jeff Cross f14b212dc9 refactor: export core APIs from angular2/core
This change moves many APIs to the angular2/core export.

This change also automatically adds FORM_BINDINGS in
the application root injector.

BREAKING CHANGE:
    Many dependencies that were previously exported from specific
    APIs are now exported from angular2/core. Affected exports, which
    should now be included from angular2/core include:

    angular2/forms
    angular2/di
    angular2/directives
    angular2/change_detection
    angular2/bootstrap (except for dart users)
    angular2/render
    angular2/metadata
    angular2/debug
    angular2/pipes
Closes #3977
2015-09-05 07:01:34 +00:00

47 lines
1.8 KiB
TypeScript

import {StringMapWrapper, ListWrapper, StringMap} from 'angular2/src/core/facade/collection';
import {bind, Binding, OpaqueToken} from 'angular2/src/core/di';
import {Validator} from './validator';
import {Metric} from './metric';
import {Options} from './common_options';
/**
* SampleDescription merges all available descriptions about a sample
*/
export class SampleDescription {
// TODO(tbosch): use static values when our transpiler supports them
static get BINDINGS(): Binding[] { return _BINDINGS; }
description: StringMap<string, any>;
constructor(public id: string, descriptions: Array<StringMap<string, any>>,
public metrics: StringMap<string, any>) {
this.description = {};
ListWrapper.forEach(descriptions, (description) => {
StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value);
});
}
toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; }
}
var _BINDINGS = [
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,
Options.DEFAULT_DESCRIPTION,
Options.SAMPLE_DESCRIPTION
])
];