Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DoubleJsonItems.cs @ 17530

Last change on this file since 17530 was 17519, checked in by dpiringe, 5 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.3 KB
Line 
1using Newtonsoft.Json.Linq;
2
3namespace HeuristicLab.JsonInterface {
4  public class DoubleJsonItem : IntervalRestrictedValueJsonItem<double> {
5    public override JObject GenerateJObject() {
6      var obj = base.GenerateJObject();
7
8      if (Minimum.CompareTo(double.MinValue) == 0)
9        obj.Property("Minimum").Remove();
10
11      if (Maximum.CompareTo(double.MaxValue) == 0)
12        obj.Property("Maximum").Remove();
13
14      return obj;
15    }
16
17    public override void SetJObject(JObject jObject) {
18      Minimum = double.MinValue;
19      Maximum = double.MaxValue;
20      base.SetJObject(jObject);
21    }
22  }
23  public class DoubleArrayJsonItem : IntervalRestrictedArrayJsonItem<double> {
24    public override JObject GenerateJObject() {
25      var obj = base.GenerateJObject();
26
27      if (Minimum.CompareTo(double.MinValue) == 0)
28        obj.Property("Minimum").Remove();
29
30      if (Maximum.CompareTo(double.MaxValue) == 0)
31        obj.Property("Maximum").Remove();
32
33      return obj;
34    }
35
36    public override void SetJObject(JObject jObject) {
37      Minimum = double.MinValue;
38      Maximum = double.MaxValue;
39      base.SetJObject(jObject);
40    }
41  }
42  public class DoubleRangeJsonItem : RangedJsonItem<double> {
43    public override JObject GenerateJObject() {
44      var obj = base.GenerateJObject();
45
46      if (Minimum.CompareTo(double.MinValue) == 0)
47        obj.Property("Minimum").Remove();
48
49      if (Maximum.CompareTo(double.MaxValue) == 0)
50        obj.Property("Maximum").Remove();
51
52      return obj;
53    }
54
55    public override void SetJObject(JObject jObject) {
56      Minimum = double.MinValue;
57      Maximum = double.MaxValue;
58      base.SetJObject(jObject);
59    }
60  }
61  public class DoubleMatrixJsonItem : IntervalRestrictedMatrixJsonItem<double> {
62    public override JObject GenerateJObject() {
63      var obj = base.GenerateJObject();
64
65      if (Minimum.CompareTo(double.MinValue) == 0)
66        obj.Property("Minimum").Remove();
67
68      if (Maximum.CompareTo(double.MaxValue) == 0)
69        obj.Property("Maximum").Remove();
70
71      return obj;
72    }
73
74    public override void SetJObject(JObject jObject) {
75      Minimum = double.MinValue;
76      Maximum = double.MaxValue;
77      base.SetJObject(jObject);
78    }
79  }
80}
Note: See TracBrowser for help on using the repository browser.