- Timestamp:
- 03/10/20 17:17:37 (4 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface
- Files:
-
- 12 added
- 1 deleted
- 30 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs
r17433 r17473 19 19 parameter.ActualValue = x; 20 20 21 if (parameter.ActualValue is IParameterizedItem &&cdata.Children != null) {21 if (parameter.ActualValue != null && /*parameter.ActualValue is IParameterizedItem &&*/ cdata.Children != null) { 22 22 foreach(var param in cdata.Children) { 23 23 if(param.Name == parameter.ActualValue.ItemName) … … 34 34 Description = value.ItemDescription, 35 35 Value = parameter.ActualValue?.ToString(), 36 Range= GetValidValues(parameter).Select(x => x.ToString())36 ConcreteRestrictedItems = GetValidValues(parameter).Select(x => x.ToString()) 37 37 }; 38 38 item.AddChildren(GetParameterizedChilds(parameter)); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/EnumTypeConverter.cs
r17433 r17473 24 24 Description = value.ItemDescription, 25 25 Value = Enum.GetName(enumType, val), 26 Range= Enum.GetNames(enumType)26 ConcreteRestrictedItems = Enum.GetNames(enumType) 27 27 }; 28 28 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/MultiCheckedOperatorConverter.cs
r17439 r17473 19 19 IJsonItem childItem = GetChildItem(op.Name, data); 20 20 if(childItem != null) { 21 if(childItem .Value is bool b) {22 val.Operators.SetItemCheckedState(op, b );21 if(childItem is BoolJsonItem boolJsonItem) { 22 val.Operators.SetItemCheckedState(op, boolJsonItem.Value); 23 23 } 24 24 root.Inject((IItem)op, childItem, root); … … 34 34 Name = op.Name, 35 35 Description = op.Description, 36 Value = val.Operators.ItemChecked(op), 37 Range = new bool[] { false, true } 36 Value = val.Operators.ItemChecked(op) 38 37 }; 39 38 IJsonItem c = root.Extract((IItem)op, root); … … 49 48 private bool GetOperatorState(string name, IJsonItem data) { 50 49 foreach(var op in data.Children) { 51 if (op.Name == name && op .Value is bool) return (bool)op.Value;50 if (op.Name == name && op is BoolJsonItem b) return b.Value; 52 51 } 53 52 return false; … … 55 54 56 55 private IJsonItem GetChildItem(string name, IJsonItem parent) { 56 if (parent.Children == null) return null; 57 57 foreach(var c in parent.Children) { 58 58 if (c.Name == name) return c; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs
r17433 r17473 24 24 var parameterizedItem = value as IParameterizedItem; 25 25 26 IJsonItem item = new JsonItem() {26 IJsonItem item = new EmptyJsonItem() { 27 27 Name = value.ItemName, 28 28 Description = value.ItemDescription -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17471 r17473 31 31 var dataInfo = dataset.GetType().GetField("variableValues", flags); 32 32 dataInfo.SetValue(dataset, dictTmp); 33 val.TargetVariable = ( string)data.Children[3].Value;34 val.TrainingPartition.Start = ((IntRangeJsonItem)data.Children[2]). Value.First();35 val.TrainingPartition.End = ((IntRangeJsonItem)data.Children[2]). Value.Last();36 val.TestPartition.Start = ((IntRangeJsonItem)data.Children[1]). Value.First();37 val.TestPartition.End = ((IntRangeJsonItem)data.Children[1]). Value.Last();33 val.TargetVariable = ((StringJsonItem)data.Children[3]).Value; 34 val.TrainingPartition.Start = ((IntRangeJsonItem)data.Children[2]).MinValue; 35 val.TrainingPartition.End = ((IntRangeJsonItem)data.Children[2]).MaxValue; 36 val.TestPartition.Start = ((IntRangeJsonItem)data.Children[1]).MinValue; 37 val.TestPartition.End = ((IntRangeJsonItem)data.Children[1]).MaxValue; 38 38 } 39 39 40 40 public override IJsonItem Extract(IItem value, IJsonItemConverter root) { 41 IJsonItem item = new JsonItem() {41 IJsonItem item = new EmptyJsonItem() { 42 42 Name = value.ItemName, 43 43 Description = value.ItemDescription … … 71 71 Name = "Dataset", 72 72 Value = mat, 73 RowNames = rowNames 73 RowNames = rowNames, 74 Minimum = double.MinValue, 75 Maximum = double.MaxValue 74 76 }); 75 77 } … … 80 82 item.AddChildren(new IntRangeJsonItem() { 81 83 Name = "TestPartition", 82 Value = new int[] { testPartition.Start, testPartition.End }, 83 Range = new int[] { 0, Math.Max(testPartition.End, trainingPartition.End) } 84 MinValue = testPartition.Start, 85 MaxValue = testPartition.End, 86 Minimum = 0, 87 Maximum = Math.Max(testPartition.End, trainingPartition.End) 84 88 }); 85 89 … … 87 91 item.AddChildren(new IntRangeJsonItem() { 88 92 Name = "TrainingPartition", 89 Value = new int[] { trainingPartition.Start, trainingPartition.End }, 90 Range = new int[] { 0, Math.Max(testPartition.End, trainingPartition.End)} 93 MinValue = trainingPartition.Start, 94 MaxValue = trainingPartition.End, 95 Minimum = 0, 96 Maximum = Math.Max(testPartition.End, trainingPartition.End) 91 97 }); 92 98 93 99 IEnumerable<StringValue> variables = (IEnumerable<StringValue>)val.InputVariables; 94 item.AddChildren(new JsonItem() {100 item.AddChildren(new StringJsonItem() { 95 101 Name = "TargetVariable", 96 Value = ( object)targetVariable,97 Range= variables.Select(x => x.Value)102 Value = (string)targetVariable, 103 ConcreteRestrictedItems = variables.Select(x => x.Value) 98 104 }); 99 105 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs
r17471 r17473 17 17 return new ResultJsonItem() { 18 18 Name = res.ActualName, 19 Value = res.ActualName,20 19 Description = res.Description 21 20 }; … … 24 23 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 25 24 IResultParameter res = item as IResultParameter; 26 res.ActualName = (string)data.Value;25 res.ActualName = data.Name; 27 26 } 28 27 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/StringValueConverter.cs
r17443 r17473 17 17 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 18 18 new StringJsonItem() { 19 Name = "[OverridableParamName]", 19 //Name = "[OverridableParamName]", 20 Name = value.ItemName, 20 21 Description = value.ItemDescription, 21 22 Value = ((StringValue)value).Value -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs
r17471 r17473 13 13 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 14 14 IValueLookupParameter param = item as IValueLookupParameter; 15 param.ActualName = CastValue<string>(((IValueLookupJsonItem)data).ActualName); 15 IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem; 16 param.ActualName = lookupItem.ActualName; 16 17 if (param.Value != null) 17 root.Inject(param.Value, data, root);18 root.Inject(param.Value, lookupItem.JsonItemReference, root); 18 19 } 19 20 … … 25 26 if (param.Value != null) { 26 27 IJsonItem tmp = root.Extract(param.Value, root); 27 item.Value = tmp.Value;28 item.Range = tmp.Range;29 item.Name = tmp.Name;30 item.Description = tmp.Description;31 28 item.AddChildren(tmp.Children); 32 item.Active = tmp.Active;33 29 item.JsonItemReference = tmp; 34 } else {35 var min = GetMinValue(param.DataType);36 var max = GetMaxValue(param.DataType);37 if (min != null && max != null)38 item.Range = new object[] { min, max };39 else40 item.Range = null;41 30 } 42 31 item.Name = param.Name; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs
r17439 r17473 14 14 IParameter parameter = value as IParameter; 15 15 16 if (parameter.ActualValue == null && data.Value != null)16 if (parameter.ActualValue == null) 17 17 parameter.ActualValue = Instantiate(parameter.DataType); 18 18 … … 21 21 root.Inject(parameter.ActualValue, data, root); 22 22 else 23 root.Inject(parameter.ActualValue, data.Children?.First(), root);23 root.Inject(parameter.ActualValue, /*data.Children?.First()*/ data, root); 24 24 25 25 } … … 29 29 IParameter parameter = value as IParameter; 30 30 31 IJsonItem item = new JsonItem() {31 IJsonItem item = new EmptyJsonItem() { 32 32 Name = parameter.Name, 33 33 Description = parameter.Description … … 37 37 IJsonItem tmp = root.Extract(parameter.ActualValue, root); 38 38 if (!(tmp is UnsupportedJsonItem)) { 39 tmp.Name = parameter.Name; 40 tmp.Description = parameter.Description; 41 item = tmp; 42 /* 39 43 if (tmp.Name == "[OverridableParamName]") { 40 44 tmp.Name = parameter.Name; … … 44 48 } else 45 49 item.AddChildren(tmp); 50 */ 46 51 } 47 52 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueRangeConverter.cs
r17451 r17473 18 18 IntRange range = item as IntRange; 19 19 IntRangeJsonItem cdata = data as IntRangeJsonItem; 20 range.Start = cdata. Value[0];21 range.End = cdata. Value[1];20 range.Start = cdata.MinValue; 21 range.End = cdata.MaxValue; 22 22 } 23 23 … … 25 25 IntRange range = value as IntRange; 26 26 return new IntRangeJsonItem() { 27 Name = "[OverridableParamName]", 27 //Name = "[OverridableParamName]", 28 Name = value.ItemName, 28 29 Description = value.ItemDescription, 29 Value = new int[] { range.Start, range.End }, 30 Range = new int[] { int.MinValue, int.MaxValue } 30 MinValue = range.Start, 31 MaxValue = range.End, 32 Minimum = int.MinValue, 33 Maximum = int.MaxValue 31 34 }; 32 35 } … … 40 43 DoubleRange range = item as DoubleRange; 41 44 DoubleRangeJsonItem cdata = data as DoubleRangeJsonItem; 42 range.Start = cdata. Value[0];43 range.End = cdata. Value[1];45 range.Start = cdata.MinValue; 46 range.End = cdata.MaxValue; 44 47 } 45 48 … … 47 50 DoubleRange range = value as DoubleRange; 48 51 return new DoubleRangeJsonItem() { 49 Name = "[OverridableParamName]", 52 //Name = "[OverridableParamName]", 53 Name = value.ItemName, 50 54 Description = value.ItemDescription, 51 Value = new double[] { range.Start, range.End }, 52 Range = new double[] { double.MinValue, double.MaxValue } 55 MinValue = range.Start, 56 MaxValue = range.End, 57 Minimum = double.MinValue, 58 Maximum = double.MaxValue 53 59 }; 54 60 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeArrayConverter.cs
r17451 r17473 30 30 Description = value.ItemDescription, 31 31 Value = ((IntArray)value).CloneAsArray(), 32 Range = new int[] { int.MinValue, int.MaxValue } 32 Minimum = int.MinValue, 33 Maximum = int.MaxValue 33 34 }; 34 35 } … … 56 57 Description = value.ItemDescription, 57 58 Value = ((DoubleArray)value).CloneAsArray(), 58 Range = new double[] { double.MinValue, double.MaxValue } 59 Minimum = double.MinValue, 60 Maximum = double.MaxValue 59 61 }; 60 62 } … … 80 82 Description = value.ItemDescription, 81 83 Value = ((PercentArray)value).CloneAsArray(), 82 Range = new double[] { 0.0d, 1.0d } 84 Minimum = 0.0d, 85 Maximum = 1.0d 83 86 }; 84 87 } … … 101 104 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 102 105 new BoolArrayJsonItem() { 103 Name = "[OverridableParamName]", 106 //Name = "[OverridableParamName]", 107 Name = value.ItemName, 104 108 Description = value.ItemDescription, 105 Value = ((BoolArray)value).CloneAsArray(), 106 Range = new bool[] { false, true } 109 Value = ((BoolArray)value).CloneAsArray() 107 110 }; 108 111 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeMatrixConverter.cs
r17471 r17473 23 23 Description = value.ItemDescription, 24 24 Value = Transform((IntMatrix)value), 25 Range = new int[] { int.MinValue, int.MaxValue } 25 Minimum = int.MinValue, 26 Maximum = int.MaxValue 26 27 }; 27 28 } … … 42 43 Description = value.ItemDescription, 43 44 Value = Transform((DoubleMatrix)value), 44 Range = new double[] { double.MinValue, double.MaxValue }, 45 Minimum = double.MinValue, 46 Maximum = double.MaxValue, 45 47 RowNames = ((DoubleMatrix)value).RowNames, 46 48 ColumnNames = ((DoubleMatrix)value).ColumnNames … … 63 65 Description = value.ItemDescription, 64 66 Value = Transform((PercentMatrix)value), 65 Range = new double[] { 0.0d, 1.0d } 67 Minimum = 0.0d, 68 Maximum = 1.0d 66 69 }; 67 70 } … … 79 82 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 80 83 new BoolMatrixJsonItem() { 81 Name = "[OverridableParamName]", 84 //Name = "[OverridableParamName]", 85 Name = value.ItemName, 82 86 Description = value.ItemDescription, 83 Value = Transform((BoolMatrix)value), 84 Range = new bool[] { false, true } 87 Value = Transform((BoolMatrix)value) 85 88 }; 86 89 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeValueConverter.cs
r17433 r17473 18 18 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 19 19 new IntJsonItem() { 20 Name = "[OverridableParamName]", 20 //Name = "[OverridableParamName]", 21 Name = value.ItemName, 21 22 Description = value.ItemDescription, 22 23 Value = ((IntValue)value).Value, 23 Range = new int[] { int.MinValue, int.MaxValue } 24 Minimum = int.MinValue, 25 Maximum = int.MaxValue 24 26 }; 25 27 } … … 34 36 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 35 37 new DoubleJsonItem() { 36 Name = "[OverridableParamName]", 38 //Name = "[OverridableParamName]", 39 Name = value.ItemName, 37 40 Description = value.ItemDescription, 38 41 Value = ((DoubleValue)value).Value, 39 Range = new double[] { double.MinValue, double.MaxValue } 42 Minimum = double.MinValue, 43 Maximum = double.MaxValue 40 44 }; 41 45 } … … 50 54 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 51 55 new DoubleJsonItem() { 52 Name = "[OverridableParamName]", 56 //Name = "[OverridableParamName]", 57 Name = value.ItemName, 53 58 Description = value.ItemDescription, 54 59 Value = ((PercentValue)value).Value, 55 Range = new double[] { double.MinValue, double.MaxValue } 60 Minimum = double.MinValue, 61 Maximum = double.MaxValue 56 62 }; 57 63 } … … 66 72 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 67 73 new BoolJsonItem() { 68 Name = "[OverridableParamName]", 74 //Name = "[OverridableParamName]", 75 Name = value.ItemName, 69 76 Description = value.ItemDescription, 70 Value = ((BoolValue)value).Value, 71 Range = new bool[] { false, true } 77 Value = ((BoolValue)value).Value 72 78 }; 73 79 } … … 82 88 public override IJsonItem Extract(IItem value, IJsonItemConverter root) => 83 89 new DateTimeJsonItem() { 84 Name = "[OverridableParamName]", 90 //Name = "[OverridableParamName]", 91 Name = value.ItemName, 85 92 Description = value.ItemDescription, 86 93 Value = ((DateTimeValue)value).Value, 87 Range = new DateTime[] { DateTime.MinValue, DateTime.MaxValue } 94 Minimum = DateTime.MinValue, 95 Maximum = DateTime.MaxValue 88 96 }; 89 97 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/HeuristicLab.JsonInterface.csproj
r17471 r17473 68 68 <Compile Include="Converters\ValueRangeConverter.cs" /> 69 69 <Compile Include="Interfaces\IArrayJsonItem.cs" /> 70 <Compile Include="Interfaces\IConcreteRestrictedJsonItem.cs" /> 71 <Compile Include="Interfaces\IIntervalRestrictedJsonItem.cs" /> 70 72 <Compile Include="Interfaces\IJsonItem.cs" /> 71 73 <Compile Include="Interfaces\IJsonItemValidator.cs" /> 72 74 <Compile Include="Interfaces\ILookupJsonItem.cs" /> 73 75 <Compile Include="Interfaces\IMatrixJsonItem.cs" /> 76 <Compile Include="Interfaces\IRangedJsonItem.cs" /> 74 77 <Compile Include="Interfaces\IResultJsonItem.cs" /> 78 <Compile Include="Interfaces\IValueJsonItem.cs" /> 75 79 <Compile Include="Interfaces\IValueLookupJsonItem.cs" /> 76 <Compile Include="Models\ArrayJsonItem Base.cs" />80 <Compile Include="Models\ArrayJsonItem.cs" /> 77 81 <Compile Include="Models\BoolJsonItems.cs" /> 82 <Compile Include="Models\ConcreteRestrictedArrayJsonItem.cs" /> 83 <Compile Include="Models\ConcreteRestrictedValueJsonItem.cs" /> 78 84 <Compile Include="Models\DateTimeJsonItem.cs" /> 79 85 <Compile Include="Models\DoubleJsonItems.cs" /> 80 <Compile Include="Models\GenericJsonItem.cs" /> 86 <Compile Include="Models\EmptyJsonItem.cs" /> 87 <Compile Include="Models\IntervalRestrictedArrayJsonItem.cs" /> 88 <Compile Include="Models\IntervalRestrictedMatrixJsonItem.cs" /> 89 <Compile Include="Models\IntervalRestrictedValueJsonItem.cs" /> 81 90 <Compile Include="Models\IntJsonItems.cs" /> 82 91 <Compile Include="Models\JsonItem.cs" /> 83 92 <Compile Include="Models\LookupJsonItem.cs" /> 84 <Compile Include="Models\MatrixJsonItemBase.cs" /> 93 <Compile Include="Models\MatrixJsonItem.cs" /> 94 <Compile Include="Models\RangedJsonItem.cs" /> 85 95 <Compile Include="Models\ResultJsonItem.cs" /> 86 96 <Compile Include="Models\StringJsonItem.cs" /> 87 97 <Compile Include="Models\UnsupportedJsonItem.cs" /> 98 <Compile Include="Models\ValueJsonItem.cs" /> 88 99 <Compile Include="Models\ValueLookupJsonItem.cs" /> 89 100 <Compile Include="SingleLineArrayJsonWriter.cs" /> -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IArrayJsonItem.cs
r17446 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public interface IArrayJsonItem : I JsonItem {8 public interface IArrayJsonItem : IValueJsonItem { 9 9 bool Resizable { get; set; } 10 10 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IJsonItem.cs
r17471 r17473 24 24 IJsonItem Parent { get; set; } 25 25 26 object Value { get; set; }26 //object Value { get; set; } 27 27 28 IEnumerable<object> Range { get; set; }28 //IEnumerable<object> Range { get; set; } 29 29 30 30 IJsonItemValidator GetValidator(); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Interfaces/IMatrixJsonItem.cs
r17471 r17473 6 6 7 7 namespace HeuristicLab.JsonInterface { 8 public interface IMatrixJsonItem : I JsonItem {8 public interface IMatrixJsonItem : IValueJsonItem { 9 9 bool RowsResizable { get; set; } 10 10 bool ColumnsResizable { get; set; } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JCGenerator.cs
r17471 r17473 62 62 IEnumerable<IJsonItem> children = item.Children; 63 63 64 if (item.Active && (item.Value != null || item.Range != null || item is IResultJsonItem || item is ILookupJsonItem)) {64 if (item.Active && !(item is EmptyJsonItem)) { 65 65 jsonItems.Add(item); 66 66 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonTemplateInstantiator.cs
r17446 r17473 105 105 instData.Objects.Add(tmp.Path, tmp); 106 106 } 107 //IList<IJsonItem> faultyItems = new List<IJsonItem>(); 108 //root.GetValidator().Validate(ref faultyItems); 107 109 } 108 110 … … 113 115 // override default value 114 116 if (instData.Objects.TryGetValue(path, out IJsonItem param)) { 115 // save range from template 116 IEnumerable<object> tmpRange = param.Range; 117 // remove fixed template parameter => dont allow to copy them from concrete config 118 obj.Property(nameof(IIntervalRestrictedJsonItem<int>.Minimum))?.Remove(); 119 obj.Property(nameof(IIntervalRestrictedJsonItem<int>.Maximum))?.Remove(); 120 obj.Property(nameof(IConcreteRestrictedJsonItem<string>.ConcreteRestrictedItems))?.Remove(); 121 // merge 117 122 param.SetFromJObject(obj); 118 // set range from template119 param.Range = tmpRange;120 123 } else throw new InvalidDataException($"No parameter with path='{path}' defined!"); 121 124 } -
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 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/SingleLineArrayJsonWriter.cs
r17442 r17473 19 19 base.Formatting = Formatting.Indented; 20 20 base.WritePropertyName(name); 21 isRangeArray = name == nameof(IJsonItem.Range) || name == nameof(IJsonItem.Value); 21 isRangeArray = 22 name == nameof(IConcreteRestrictedJsonItem<int>.ConcreteRestrictedItems) || 23 name == nameof(IValueJsonItem.Value) || 24 name == nameof(IMatrixJsonItem.RowNames) || 25 name == nameof(IMatrixJsonItem.ColumnNames); 22 26 } 23 27
Note: See TracChangeset
for help on using the changeset viewer.