1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Reflection;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 | using HeuristicLab.Common;
|
---|
8 | using HeuristicLab.Core;
|
---|
9 | using HeuristicLab.Data;
|
---|
10 |
|
---|
11 | namespace HeuristicLab.JsonInterface {
|
---|
12 |
|
---|
13 | public class IntRangeConverter : BaseConverter {
|
---|
14 | public override int Priority => 1;
|
---|
15 | public override Type ConvertableType => typeof(IntRange);
|
---|
16 |
|
---|
17 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
18 | IntRange range = item as IntRange;
|
---|
19 | IntArrayJsonItem cdata = data as IntArrayJsonItem;
|
---|
20 | range.Start = cdata.Value[0];
|
---|
21 | range.End = cdata.Value[1];
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
25 | IntRange range = value as IntRange;
|
---|
26 | return new IntRangeJsonItem() {
|
---|
27 | Name = "[OverridableParamName]",
|
---|
28 | Description = value.ItemDescription,
|
---|
29 | Value = new int[] { range.Start, range.End },
|
---|
30 | Range = new int[] { int.MinValue, int.MaxValue }
|
---|
31 | };
|
---|
32 | }
|
---|
33 | }
|
---|
34 |
|
---|
35 | public class DoubleRangeConverter : BaseConverter {
|
---|
36 | public override int Priority => 1;
|
---|
37 | public override Type ConvertableType => typeof(DoubleRange);
|
---|
38 |
|
---|
39 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
40 | DoubleRange range = item as DoubleRange;
|
---|
41 | DoubleArrayJsonItem cdata = data as DoubleArrayJsonItem;
|
---|
42 | range.Start = cdata.Value[0];
|
---|
43 | range.End = cdata.Value[1];
|
---|
44 | }
|
---|
45 |
|
---|
46 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
47 | DoubleRange range = value as DoubleRange;
|
---|
48 | return new DoubleRangeJsonItem() {
|
---|
49 | Name = "[OverridableParamName]",
|
---|
50 | Description = value.ItemDescription,
|
---|
51 | Value = new double[] { range.Start, range.End },
|
---|
52 | Range = new double[] { double.MinValue, double.MaxValue }
|
---|
53 | };
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|