- Timestamp:
- 02/18/20 16:28:53 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs
r17443 r17444 16 16 base.Inject(item, data, root); 17 17 IAlgorithm algorithm = item as IAlgorithm; 18 IJsonItem problemData = data.Children.Where(x => x.Name == algorithm.Problem.ItemName).First(); 19 root.Inject(algorithm.Problem, problemData, root); 20 18 var collection = data.Children.Where(x => x.Name == algorithm.Problem.ItemName); 19 if(collection.Count() > 0) { 20 IJsonItem problemData = collection.First(); 21 root.Inject(algorithm.Problem, problemData, root); 22 } 21 23 } 22 24 … … 27 29 item.AddChildren(new ResultItem() { 28 30 Name = res.Name, 29 Description = res.Description, 30 Value = true, 31 Range = new object[] { true, false } 31 Description = res.Description 32 32 }); 33 33 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs
r17433 r17444 33 33 34 34 void AddChildren(IEnumerable<IJsonItem> childs); 35 36 /// <summary> 37 /// This method fixates the path. 38 /// After calling, the path cannot be changed by changing the name or parent. 39 /// </summary> 40 void FixatePath(); 41 42 /// <summary> 43 /// This method looses the path again after a call of FixatePath. 44 /// After calling, the path is calculated by the position in item tree again. 45 /// </summary> 46 void LoosenPath(); 35 47 } 36 48 } -
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.