- Timestamp:
- 02/18/20 16:28:53 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs
r17435 r17444 45 45 public virtual string Description { get; set; } 46 46 47 private string fixedPath = ""; 47 48 public virtual string Path { 48 49 get { 50 if (!string.IsNullOrWhiteSpace(fixedPath)) 51 return fixedPath; 52 49 53 IJsonItem tmp = Parent; 50 54 StringBuilder builder = new StringBuilder(this.Name); … … 57 61 } 58 62 63 public virtual object Value { get; set; } 64 65 public virtual IEnumerable<object> Range { get; set; } 66 67 public virtual string ActualName { get; set; } 68 59 69 [JsonIgnore] 60 70 public virtual IList<IJsonItem> Children { get; protected set; } … … 62 72 [JsonIgnore] 63 73 public virtual IJsonItem Parent { get; set; } 64 65 public virtual object Value { get; set; }66 67 public virtual IEnumerable<object> Range { get; set; }68 69 public virtual string ActualName { get; set; }70 74 71 75 #region Constructors … … 97 101 98 102 public void AddChildren(IEnumerable<IJsonItem> childs) { 103 if (childs == null) return; 99 104 if (Children == null) 100 105 Children = new List<IJsonItem>(); … … 106 111 107 112 public virtual IJsonItemValidator GetValidator() => new JsonItemValidator(this); 113 114 public void FixatePath() => fixedPath = Path; 115 public void LoosenPath() => fixedPath = ""; 108 116 #endregion 109 117 110 118 #region Helper 111 protected bool IsInRange() {119 protected virtual bool IsInRange() { 112 120 bool b1 = true, b2 = true; 113 121 if (Value is IEnumerable && !(Value is string)) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItems.cs
r17420 r17444 9 9 public class IntArrayJsonItem: JsonItem<int[], int> { } 10 10 public class IntRangeJsonItem : JsonItem<int[], int> { } 11 public class IntMatrixJsonItem : JsonItem<int[][], int> { } 11 public class IntMatrixJsonItem : JsonItem<int[][], int> { 12 protected override bool IsInRange() { 13 for (int c = 0; c < Value.Length; ++c) { 14 for (int r = 0; r < Value[c].Length; ++r) { 15 if (Value[c][r] < Range.First() && Range.Last() < Value[c][r]) 16 return false; 17 } 18 } 19 return true; 20 } 21 } 12 22 13 23 public class DoubleJsonItem: JsonItem<double> {} 14 24 public class DoubleArrayJsonItem: JsonItem<double[], double> { } 15 25 public class DoubleRangeJsonItem : JsonItem<double[], double> { } 16 public class DoubleMatrixJsonItem : JsonItem<double[][], double> { } 26 public class DoubleMatrixJsonItem : JsonItem<double[][], double> { 27 protected override bool IsInRange() { 28 for(int c = 0; c < Value.Length; ++c) { 29 for(int r = 0; r < Value[c].Length; ++r) { 30 if (Value[c][r] < Range.First() && Range.Last() < Value[c][r]) 31 return false; 32 } 33 } 34 return true; 35 } 36 } 17 37 18 38 public class BoolJsonItem: JsonItem<bool> { }
Note: See TracChangeset
for help on using the changeset viewer.