[17353] | 1 | using System;
|
---|
| 2 | using HeuristicLab.Core;
|
---|
| 3 | using HeuristicLab.Data;
|
---|
| 4 |
|
---|
| 5 | namespace HeuristicLab.JsonInterface {
|
---|
| 6 |
|
---|
[17410] | 7 | public class IntRangeConverter : BaseConverter {
|
---|
[17394] | 8 | public override int Priority => 1;
|
---|
[17410] | 9 |
|
---|
[17828] | 10 | public override bool CanConvertType(Type t) =>
|
---|
[17843] | 11 | typeof(IntRange).IsAssignableFrom(t);
|
---|
[17828] | 12 |
|
---|
[17410] | 13 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
| 14 | IntRange range = item as IntRange;
|
---|
[17451] | 15 | IntRangeJsonItem cdata = data as IntRangeJsonItem;
|
---|
[17473] | 16 | range.Start = cdata.MinValue;
|
---|
| 17 | range.End = cdata.MaxValue;
|
---|
[17410] | 18 | }
|
---|
| 19 |
|
---|
| 20 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
| 21 | IntRange range = value as IntRange;
|
---|
[17420] | 22 | return new IntRangeJsonItem() {
|
---|
[17473] | 23 | Name = value.ItemName,
|
---|
[17433] | 24 | Description = value.ItemDescription,
|
---|
[17473] | 25 | MinValue = range.Start,
|
---|
| 26 | MaxValue = range.End,
|
---|
| 27 | Minimum = int.MinValue,
|
---|
| 28 | Maximum = int.MaxValue
|
---|
[17410] | 29 | };
|
---|
| 30 | }
|
---|
[17394] | 31 | }
|
---|
[17410] | 32 |
|
---|
| 33 | public class DoubleRangeConverter : BaseConverter {
|
---|
[17394] | 34 | public override int Priority => 1;
|
---|
[17353] | 35 |
|
---|
[17828] | 36 | public override bool CanConvertType(Type t) =>
|
---|
[17843] | 37 | typeof(DoubleRange).IsAssignableFrom(t);
|
---|
[17828] | 38 |
|
---|
[17407] | 39 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
[17410] | 40 | DoubleRange range = item as DoubleRange;
|
---|
[17451] | 41 | DoubleRangeJsonItem cdata = data as DoubleRangeJsonItem;
|
---|
[17473] | 42 | range.Start = cdata.MinValue;
|
---|
| 43 | range.End = cdata.MaxValue;
|
---|
[17353] | 44 | }
|
---|
[17407] | 45 |
|
---|
| 46 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
[17410] | 47 | DoubleRange range = value as DoubleRange;
|
---|
[17420] | 48 | return new DoubleRangeJsonItem() {
|
---|
[17473] | 49 | Name = value.ItemName,
|
---|
[17433] | 50 | Description = value.ItemDescription,
|
---|
[17473] | 51 | MinValue = range.Start,
|
---|
| 52 | MaxValue = range.End,
|
---|
| 53 | Minimum = double.MinValue,
|
---|
| 54 | Maximum = double.MaxValue
|
---|
[17407] | 55 | };
|
---|
| 56 | }
|
---|
[17353] | 57 | }
|
---|
| 58 | }
|
---|