1 | import {StringMapWrapper} from 'angular2/src/facade/collection';
|
2 | import {bind, provide, Provider, OpaqueToken} from 'angular2/src/core/di';
|
3 | import {Validator} from './validator';
|
4 | import {Metric} from './metric';
|
5 | import {Options} from './common_options';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export class SampleDescription {
|
11 |
|
12 | static get BINDINGS(): Provider[] { return _PROVIDERS; }
|
13 | description: {[key: string]: any};
|
14 |
|
15 | constructor(public id: string, descriptions: Array<{[key: string]: any}>,
|
16 | public metrics: {[key: string]: any}) {
|
17 | this.description = {};
|
18 | descriptions.forEach(description => {
|
19 | StringMapWrapper.forEach(description, (value, prop) => this.description[prop] = value);
|
20 | });
|
21 | }
|
22 |
|
23 | toJson() { return {'id': this.id, 'description': this.description, 'metrics': this.metrics}; }
|
24 | }
|
25 |
|
26 | var _PROVIDERS = [
|
27 | bind(SampleDescription)
|
28 | .toFactory((metric, id, forceGc, userAgent, validator, defaultDesc, userDesc) =>
|
29 | new SampleDescription(id,
|
30 | [
|
31 | {'forceGc': forceGc, 'userAgent': userAgent},
|
32 | validator.describe(),
|
33 | defaultDesc,
|
34 | userDesc
|
35 | ],
|
36 | metric.describe()),
|
37 | [
|
38 | Metric,
|
39 | Options.SAMPLE_ID,
|
40 | Options.FORCE_GC,
|
41 | Options.USER_AGENT,
|
42 | Validator,
|
43 | Options.DEFAULT_DESCRIPTION,
|
44 | Options.SAMPLE_DESCRIPTION
|
45 | ])
|
46 | ];
|