source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/DoubleJsonItems.cs @ 18055

Last change on this file since 18055 was 18055, checked in by dpiringe, 11 months ago

#3026

  • added StorableTypeAttribute and StorableConstructorAttribute to all JsonItems
  • added a new JsonItem ListJsonItem + Interfaces IListJsonItem
  • renamed SymRegPythonProcessor to RunCollectionSRSolutionPythonFormatter
  • removed Interface IResultCollectionProcessor -> using the interface IRunCollectionModifier now (has aleady implementations)
  • renamed all related variables/fields/properties with a connection to ResultCollectionProcessor
  • added new implementations for IRunCollectionModifier
File size: 3.1 KB
Line 
1using Newtonsoft.Json.Linq;
2using HEAL.Attic;
3
4namespace HeuristicLab.JsonInterface {
5  [StorableType("B9B3843E-90B9-453F-AB7F-B3A4B8DF6809")]
6  public class DoubleJsonItem : IntervalRestrictedValueJsonItem<double> {
7    public override JObject GenerateJObject() {
8      var obj = base.GenerateJObject();
9
10      if (Minimum.CompareTo(double.MinValue) == 0)
11        obj.Property("Minimum").Remove();
12
13      if (Maximum.CompareTo(double.MaxValue) == 0)
14        obj.Property("Maximum").Remove();
15
16      return obj;
17    }
18
19    public override void SetJObject(JObject jObject) {
20      Minimum = double.MinValue;
21      Maximum = double.MaxValue;
22      base.SetJObject(jObject);
23    }
24
25    public DoubleJsonItem() { }
26
27    [StorableConstructor]
28    protected DoubleJsonItem(StorableConstructorFlag _) : base(_) { }
29  }
30
31  [StorableType("D7E2BA3D-E9F7-4062-8423-182B517FA7CA")]
32  public class DoubleArrayJsonItem : IntervalRestrictedArrayJsonItem<double> {
33    public override JObject GenerateJObject() {
34      var obj = base.GenerateJObject();
35
36      if (Minimum.CompareTo(double.MinValue) == 0)
37        obj.Property("Minimum").Remove();
38
39      if (Maximum.CompareTo(double.MaxValue) == 0)
40        obj.Property("Maximum").Remove();
41
42      return obj;
43    }
44
45    public override void SetJObject(JObject jObject) {
46      Minimum = double.MinValue;
47      Maximum = double.MaxValue;
48      base.SetJObject(jObject);
49    }
50
51    public DoubleArrayJsonItem() { }
52
53    [StorableConstructor]
54    protected DoubleArrayJsonItem(StorableConstructorFlag _) : base(_) { }
55  }
56
57  [StorableType("4ED29A62-F368-476B-B551-4283E428F7B9")]
58  public class DoubleRangeJsonItem : RangedJsonItem<double> {
59    public override JObject GenerateJObject() {
60      var obj = base.GenerateJObject();
61
62      if (Minimum.CompareTo(double.MinValue) == 0)
63        obj.Property("Minimum").Remove();
64
65      if (Maximum.CompareTo(double.MaxValue) == 0)
66        obj.Property("Maximum").Remove();
67
68      return obj;
69    }
70
71    public override void SetJObject(JObject jObject) {
72      Minimum = double.MinValue;
73      Maximum = double.MaxValue;
74      base.SetJObject(jObject);
75    }
76
77    public DoubleRangeJsonItem() { }
78
79    [StorableConstructor]
80    protected DoubleRangeJsonItem(StorableConstructorFlag _) : base(_) { }
81  }
82
83  [StorableType("39C117DA-6274-4C1F-8CA8-A57B1A7A9C72")]
84  public class DoubleMatrixJsonItem : IntervalRestrictedMatrixJsonItem<double> {
85    public override JObject GenerateJObject() {
86      var obj = base.GenerateJObject();
87
88      if (Minimum.CompareTo(double.MinValue) == 0)
89        obj.Property("Minimum").Remove();
90
91      if (Maximum.CompareTo(double.MaxValue) == 0)
92        obj.Property("Maximum").Remove();
93
94      return obj;
95    }
96
97    public override void SetJObject(JObject jObject) {
98      Minimum = double.MinValue;
99      Maximum = double.MaxValue;
100      base.SetJObject(jObject);
101    }
102
103    public DoubleMatrixJsonItem() { }
104
105    [StorableConstructor]
106    protected DoubleMatrixJsonItem(StorableConstructorFlag _) : base(_) { }
107  }
108}
Note: See TracBrowser for help on using the repository browser.