source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntJsonItems.cs @ 17519

Last change on this file since 17519 was 17519, checked in by dpiringe, 2 years ago

#3026:

  • added error output for failed runner initialization
  • reorganised some final view models
  • TargetedJsonItemType (in JsonItemVMBase) now automatically returns the type of the defined JsonItem
  • code cleanup
  • refactored RegressionProblemDataConverter
  • added lots of comments
  • added new view for StringArrayJsonItem
  • added new UI component for concrete restricted items and used it in JsonItemConcreteItemArrayControl and JsonItemValidValuesControl
File size: 2.2 KB
Line 
1using Newtonsoft.Json.Linq;
2
3namespace HeuristicLab.JsonInterface {
4  public class IntJsonItem : IntervalRestrictedValueJsonItem<int> {
5    public override JObject GenerateJObject() {
6      var obj = base.GenerateJObject();
7
8      if (Minimum.CompareTo(int.MinValue) == 0)
9        obj.Property("Minimum").Remove();
10
11      if (Maximum.CompareTo(int.MaxValue) == 0)
12        obj.Property("Maximum").Remove();
13
14      return obj;
15    }
16
17    public override void SetJObject(JObject jObject) {
18      Minimum = int.MinValue;
19      Maximum = int.MaxValue;
20      base.SetJObject(jObject);
21    }
22  }
23  public class IntArrayJsonItem : IntervalRestrictedArrayJsonItem<int> {
24    public override JObject GenerateJObject() {
25      var obj = base.GenerateJObject();
26
27      if (Minimum.CompareTo(int.MinValue) == 0)
28        obj.Property("Minimum").Remove();
29
30      if (Maximum.CompareTo(int.MaxValue) == 0)
31        obj.Property("Maximum").Remove();
32
33      return obj;
34    }
35
36    public override void SetJObject(JObject jObject) {
37      Minimum = int.MinValue;
38      Maximum = int.MaxValue;
39      base.SetJObject(jObject);
40    }
41  }
42  public class IntRangeJsonItem : RangedJsonItem<int> {
43    public override JObject GenerateJObject() {
44      var obj = base.GenerateJObject();
45
46      if (Minimum.CompareTo(int.MinValue) == 0)
47        obj.Property("Minimum").Remove();
48
49      if (Maximum.CompareTo(int.MaxValue) == 0)
50        obj.Property("Maximum").Remove();
51
52      return obj;
53    }
54
55    public override void SetJObject(JObject jObject) {
56      Minimum = int.MinValue;
57      Maximum = int.MaxValue;
58      base.SetJObject(jObject);
59    }
60  }
61  public class IntMatrixJsonItem : IntervalRestrictedMatrixJsonItem<int> {
62    public override JObject GenerateJObject() {
63      var obj = base.GenerateJObject();
64
65      if (Minimum.CompareTo(int.MinValue) == 0)
66        obj.Property("Minimum").Remove();
67
68      if (Maximum.CompareTo(int.MaxValue) == 0)
69        obj.Property("Maximum").Remove();
70
71      return obj;
72    }
73
74    public override void SetJObject(JObject jObject) {
75      Minimum = int.MinValue;
76      Maximum = int.MaxValue;
77      base.SetJObject(jObject);
78    }
79  }
80}
Note: See TracBrowser for help on using the repository browser.