- Timestamp:
- 03/10/20 17:17:37 (5 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models
- Files:
-
- 8 added
- 1 deleted
- 10 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ArrayJsonItem.cs
r17472 r17473 7 7 8 8 namespace HeuristicLab.JsonInterface { 9 public class ArrayJsonItemBase<T> : JsonItem<T[], T>, IArrayJsonItem {9 public abstract class ArrayJsonItem<T> : ValueJsonItem<T[]>, IArrayJsonItem { 10 10 public virtual bool Resizable { get; set; } 11 11 public override void SetFromJObject(JObject jObject) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/BoolJsonItems.cs
r17446 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class BoolJsonItem : JsonItem<bool> { } 8 public class BoolJsonItem : ValueJsonItem<bool> { 9 protected override bool Validate() => true; 10 } 9 11 10 public class BoolArrayJsonItem : ArrayJsonItemBase<bool> { } 12 public class BoolArrayJsonItem : ArrayJsonItem<bool> { 13 protected override bool Validate() => true; 14 } 11 15 12 public class BoolMatrixJsonItem : MatrixJsonItemBase<bool> { } 16 public class BoolMatrixJsonItem : MatrixJsonItem<bool> { 17 protected override bool Validate() => true; 18 } 13 19 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DateTimeJsonItem.cs
r17446 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class DateTimeJsonItem : JsonItem<DateTime> { } 8 public class DateTimeJsonItem : IntervalRestrictedValueJsonItem<DateTime> { 9 protected override bool Validate() => Minimum.CompareTo(Value) >= 0 && Maximum.CompareTo(Value) <= 0; 10 } 9 11 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/DoubleJsonItems.cs
r17471 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class DoubleJsonItem : JsonItem<double> { } 9 public class DoubleArrayJsonItem : ArrayJsonItemBase<double> { } 10 public class DoubleRangeJsonItem : ArrayJsonItemBase<double> { 11 public override bool Resizable { get => false; set { } } 12 } 8 public class DoubleJsonItem : IntervalRestrictedValueJsonItem<double> { } 9 public class DoubleArrayJsonItem : IntervalRestrictedArrayJsonItem<double> { } 10 public class DoubleRangeJsonItem : RangedJsonItem<double> { } 13 11 14 public class DoubleMatrixJsonItem : MatrixJsonItemBase<double> { 12 public class DoubleMatrixJsonItem : IntervalRestrictedMatrixJsonItem<double> { 13 /* 15 14 protected override bool IsInRange() { 16 15 for (int c = 0; c < Value.Length; ++c) { … … 22 21 return true; 23 22 } 23 */ 24 24 } 25 25 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/IntJsonItems.cs
r17471 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class IntJsonItem : JsonItem<int> { 9 //public new IEnumerable<int> Range { get; } 8 public class IntJsonItem : IntervalRestrictedValueJsonItem<int> { } 9 public class IntArrayJsonItem : IntervalRestrictedArrayJsonItem<int> { } 10 public class IntRangeJsonItem : RangedJsonItem<int> { } 11 public class IntMatrixJsonItem : IntervalRestrictedMatrixJsonItem<int> { 10 12 /* 11 public int MinValue { get; set; }12 public int MaxValue { get; set; }13 */14 }15 public class IntArrayJsonItem : ArrayJsonItemBase<int> { }16 public class IntRangeJsonItem : ArrayJsonItemBase<int> {17 public override bool Resizable { get => false; set { } }18 }19 public class IntMatrixJsonItem : MatrixJsonItemBase<int> {20 21 13 protected override bool IsInRange() { 22 14 for (int c = 0; c < Value.Length; ++c) { … … 28 20 return true; 29 21 } 22 */ 30 23 } 31 24 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/JsonItem.cs
r17471 r17473 11 11 /// Main data class for json interface. 12 12 /// </summary> 13 public class JsonItem : IJsonItem {13 public abstract class JsonItem : IJsonItem { 14 14 15 15 public class JsonItemValidator : IJsonItemValidator { … … 25 25 } 26 26 27 // TODO: return ValidationResult ? 27 28 private bool ValidateHelper(JsonItem item, ref IList<IJsonItem> faultyItems) { 28 29 int hash = item.GetHashCode(); … … 30 31 return r; 31 32 32 bool res = true; 33 if (item.Value != null && item.Range != null) 34 res = item.IsInRange(); 33 bool res = item.Validate(); 35 34 if (!res) faultyItems.Add(item); 36 35 Cache.Add(hash, res); 37 if(item.Children != null) 36 if(item.Children != null) { 38 37 foreach (var child in item.Children) 39 res = res && ValidateHelper(child as JsonItem, ref faultyItems); 38 if (!ValidateHelper(child as JsonItem, ref faultyItems)) 39 res = false && res; 40 } 40 41 return res; 41 42 } … … 62 63 } 63 64 64 public virtual object Value { get; set; }65 //public virtual object Value { get; set; } 65 66 66 public virtual IEnumerable<object> Range { get; set; }67 //public virtual IEnumerable<object> Range { get; set; } 67 68 68 69 // TODO jsonIgnore dataType? … … 105 106 106 107 public virtual void SetFromJObject(JObject jObject) { 107 Value = jObject[nameof(IJsonItem.Value)]?.ToObject<object>();108 Range = jObject[nameof(IJsonItem.Range)]?.ToObject<object[]>();108 //Value = jObject[nameof(IJsonItem.Value)]?.ToObject<object>(); 109 //Range = jObject[nameof(IJsonItem.Range)]?.ToObject<object[]>(); 109 110 } 110 111 #endregion … … 114 115 * TODO protected abstract bool Validate(); 115 116 */ 116 117 protected abstract bool Validate(); 118 /* 117 119 protected virtual bool IsInRange() { 118 120 bool b1 = true, b2 = true; … … 156 158 (((T)max).CompareTo(value) == 1 || ((T)max).CompareTo(value) == 0); 157 159 } 160 */ 158 161 #endregion 159 162 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/LookupJsonItem.cs
r17471 r17473 14 14 ActualName = jObject[nameof(ILookupJsonItem.ActualName)]?.ToString(); 15 15 } 16 17 protected override bool Validate() => true; 16 18 } 17 19 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/MatrixJsonItem.cs
r17472 r17473 7 7 8 8 namespace HeuristicLab.JsonInterface { 9 public class MatrixJsonItemBase<T> : JsonItem<T[][], T>, IMatrixJsonItem {9 public abstract class MatrixJsonItem<T> : ValueJsonItem<T[][]>, IMatrixJsonItem { 10 10 public virtual bool RowsResizable { get; set; } 11 11 public virtual bool ColumnsResizable { get; set; } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ResultJsonItem.cs
r17471 r17473 7 7 namespace HeuristicLab.JsonInterface { 8 8 public class ResultJsonItem : JsonItem, IResultJsonItem { 9 9 protected override bool Validate() => true; 10 10 } 11 11 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/StringJsonItem.cs
r17451 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public class StringJsonItem : JsonItem<string> { }9 public class StringArrayJsonItem : JsonItem<string[],string> { }8 public class StringJsonItem : ConcreteRestrictedValueJsonItem<string> { } 9 public class StringArrayJsonItem : ConcreteRestrictedArrayJsonItem<string> { } 10 10 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/UnsupportedJsonItem.cs
r17471 r17473 34 34 } 35 35 36 public override object Value { 37 get => throw new NotSupportedException(); 38 set => throw new NotSupportedException(); 39 } 40 41 public override IEnumerable<object> Range { 42 get => throw new NotSupportedException(); 43 set => throw new NotSupportedException(); 44 } 36 protected override bool Validate() => true; 45 37 } 46 38 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ValueLookupJsonItem.cs
r17471 r17473 10 10 [JsonIgnore] 11 11 public IJsonItem JsonItemReference { get; set; } 12 13 protected override bool Validate() { 14 if (JsonItemReference == null) return true; 15 IList<IJsonItem> faultyItems = new List<IJsonItem>(); 16 return JsonItemReference.GetValidator().Validate(ref faultyItems); 17 } 12 18 } 13 19 }
Note: See TracChangeset
for help on using the changeset viewer.