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 | IntRangeJsonItem cdata = data as IntRangeJsonItem;
|
---|
20 | range.Start = cdata.MinValue;
|
---|
21 | range.End = cdata.MaxValue;
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
25 | IntRange range = value as IntRange;
|
---|
26 | return new IntRangeJsonItem() {
|
---|
27 | Name = value.ItemName,
|
---|
28 | Description = value.ItemDescription,
|
---|
29 | MinValue = range.Start,
|
---|
30 | MaxValue = range.End,
|
---|
31 | Minimum = int.MinValue,
|
---|
32 | Maximum = int.MaxValue
|
---|
33 | };
|
---|
34 | }
|
---|
35 | }
|
---|
36 |
|
---|
37 | public class DoubleRangeConverter : BaseConverter {
|
---|
38 | public override int Priority => 1;
|
---|
39 | public override Type ConvertableType => typeof(DoubleRange);
|
---|
40 |
|
---|
41 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
42 | DoubleRange range = item as DoubleRange;
|
---|
43 | DoubleRangeJsonItem cdata = data as DoubleRangeJsonItem;
|
---|
44 | range.Start = cdata.MinValue;
|
---|
45 | range.End = cdata.MaxValue;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
49 | DoubleRange range = value as DoubleRange;
|
---|
50 | return new DoubleRangeJsonItem() {
|
---|
51 | Name = value.ItemName,
|
---|
52 | Description = value.ItemDescription,
|
---|
53 | MinValue = range.Start,
|
---|
54 | MaxValue = range.End,
|
---|
55 | Minimum = double.MinValue,
|
---|
56 | Maximum = double.MaxValue
|
---|
57 | };
|
---|
58 | }
|
---|
59 | }
|
---|
60 | }
|
---|