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