- Timestamp:
- 02/01/21 14:37:18 (4 years ago)
- Location:
- branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs
r17451 r17828 12 12 13 13 public override Type ConvertableType => typeof(IAlgorithm); 14 15 public override bool CanConvertType(Type t) => 16 t.GetInterfaces().Any(x => x == ConvertableType); 14 17 15 18 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs
r17477 r17828 12 12 { 13 13 public abstract int Priority { get; } 14 15 public abstract bool CanConvertType(Type t); 16 14 17 public abstract Type ConvertableType { get; } 15 18 -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BatchRunConverter.cs
r17540 r17828 10 10 public override int Priority => 10; 11 11 public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("E85407E0-18EC-4198-8321-9CF030FDF6D7")); 12 13 public override bool CanConvertType(Type t) => ConvertableType.IsAssignableFrom(t); 12 14 13 15 public override IJsonItem Extract(IItem value, IJsonItemConverter root) { … … 31 33 Maximum = int.MaxValue 32 34 }); 33 34 35 return batchRunJI; 35 36 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs
r17485 r17828 11 11 public override int Priority => 3; 12 12 public override Type ConvertableType => typeof(IConstrainedValueParameter<>); 13 14 public override bool CanConvertType(Type t) => 15 t.GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IConstrainedValueParameter<>)); 13 16 14 17 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/EnumTypeConverter.cs
r17473 r17828 11 11 public override int Priority => 1; 12 12 public override Type ConvertableType => typeof(EnumValue<>); 13 14 public override bool CanConvertType(Type t) => 15 typeof(EnumValue<>).IsAssignableFrom(t) || 16 (t.IsGenericType && t.GetGenericTypeDefinition() == ConvertableType); 13 17 14 18 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => … … 25 29 Value = Enum.GetName(enumType, val), 26 30 ConcreteRestrictedItems = Enum.GetNames(enumType) 27 };31 }; 28 32 } 29 33 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ExperimentConverter.cs
r17540 r17828 11 11 public override int Priority => 10; 12 12 public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("A8A4536B-54C1-4A17-AB58-A6006F7F394B")); 13 14 public override bool CanConvertType(Type t) => 15 ConvertableType.IsAssignableFrom(t); 13 16 14 17 public override IJsonItem Extract(IItem value, IJsonItemConverter root) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/LookupParameterConverter.cs
r17471 r17828 10 10 public override int Priority => 3; 11 11 public override Type ConvertableType => typeof(ILookupParameter); 12 12 13 public override bool CanConvertType(Type t) => 14 t.GetInterfaces().Any(x => x == typeof(ILookupParameter)); 15 13 16 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 14 17 ((ILookupParameter)item).ActualName = ((ILookupJsonItem)data).ActualName as string; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/MultiCheckedOperatorConverter.cs
r17484 r17828 10 10 public class MultiCheckedOperatorConverter : ParameterizedItemConverter { 11 11 public override int Priority => 3; 12 12 13 public override Type ConvertableType => typeof(ICheckedMultiOperator<>); 13 14 15 public override bool CanConvertType(Type t) => 16 t.GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == ConvertableType); 17 14 18 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 15 19 base.Inject(item, data, root); -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs
r17473 r17828 10 10 public override int Priority => 2; 11 11 public override Type ConvertableType => typeof(IParameterizedItem); 12 13 public override bool CanConvertType(Type t) => 14 t.GetInterfaces().Any(x => x == typeof(IParameterizedItem)); 12 15 13 16 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { … … 39 42 return item; 40 43 } 44 41 45 } 42 46 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs
r17560 r17828 34 34 public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("EE612297-B1AF-42D2-BF21-AF9A2D42791C")); 35 35 36 public override bool CanConvertType(Type t) => 37 ConvertableType.IsAssignableFrom(t); 38 36 39 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 37 40 … … 180 183 if(it != null) { 181 184 if(it.MoveNext() && it.Current is double) { 182 CreateMatrix(dict, out IList<string> rowNames, out double[][] mat);185 CreateMatrix(dict, out IList<string> columnNames, out double[][] mat); 183 186 return new DoubleMatrixJsonItem() { 184 187 Name = Dataset, 185 188 Value = mat, 186 RowNames = rowNames,189 ColumnNames = columnNames, 187 190 Minimum = double.MinValue, 188 191 Maximum = double.MaxValue 189 192 }; 190 193 } else if(it.Current is int) { 191 CreateMatrix(dict, out IList<string> rowNames, out int[][] mat);194 CreateMatrix(dict, out IList<string> columnNames, out int[][] mat); 192 195 return new IntMatrixJsonItem() { 193 196 Name = Dataset, 194 197 Value = mat, 195 RowNames = rowNames,198 ColumnNames = columnNames, 196 199 Minimum = int.MinValue, 197 200 Maximum = int.MaxValue 198 201 }; 199 202 } else if (it.Current is bool) { 200 CreateMatrix(dict, out IList<string> rowNames, out bool[][] mat);203 CreateMatrix(dict, out IList<string> columnNames, out bool[][] mat); 201 204 return new BoolMatrixJsonItem() { 202 205 Name = Dataset, 203 206 Value = mat, 204 RowNames = rowNames207 ColumnNames = columnNames 205 208 }; 206 209 } … … 210 213 } 211 214 212 private void CreateMatrix<T>(Dictionary<string, IList> dict, out IList<string> rowNames, out T[][] matrix) {215 private void CreateMatrix<T>(Dictionary<string, IList> dict, out IList<string> columnNames, out T[][] matrix) { 213 216 int cols = dict.Count, rows = 0, c = 0; 214 rowNames = new List<string>();217 columnNames = new List<string>(); 215 218 matrix = new T[cols][]; 216 219 foreach (var x in dict) { 217 220 rows = Math.Max(rows, x.Value.Count); 218 rowNames.Add(x.Key);221 columnNames.Add(x.Key); 219 222 220 223 matrix[c] = new T[rows]; 224 221 225 int r = 0; 222 223 foreach (var rowValue in x.Value) { 224 matrix[c][r] = (T)rowValue; 226 foreach (var callValue in x.Value) { 227 matrix[c][r] = (T)callValue; 225 228 ++r; 226 229 } -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs
r17473 r17828 12 12 13 13 public override Type ConvertableType => typeof(IResultParameter); 14 15 public override bool CanConvertType(Type t) => 16 t.GetInterfaces().Any(x => x == typeof(IResultParameter)); 14 17 15 18 public override IJsonItem Extract(IItem value, IJsonItemConverter root) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/StringValueConverter.cs
r17483 r17828 12 12 public override Type ConvertableType => typeof(StringValue); 13 13 14 public override bool CanConvertType(Type t) => 15 ConvertableType.IsAssignableFrom(t); 16 14 17 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 15 18 ((StringValue)item).Value = ((StringJsonItem)data).Value; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs
r17483 r17828 10 10 public override int Priority => 4; 11 11 public override Type ConvertableType => typeof(IValueLookupParameter); 12 13 public override bool CanConvertType(Type t) => 14 t.GetInterfaces().Any(x => x == typeof(IValueLookupParameter)); 12 15 13 16 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs
r17519 r17828 10 10 public override int Priority => 2; 11 11 public override Type ConvertableType => typeof(IValueParameter); 12 13 public override bool CanConvertType(Type t) => 14 t.GetInterfaces().Any(x => x == typeof(IValueParameter)); 12 15 13 16 public override void Inject(IItem value, IJsonItem data, IJsonItemConverter root) { -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueRangeConverter.cs
r17483 r17828 14 14 public override int Priority => 1; 15 15 public override Type ConvertableType => typeof(IntRange); 16 17 public override bool CanConvertType(Type t) => 18 ConvertableType.IsAssignableFrom(t); 16 19 17 20 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { … … 39 42 public override Type ConvertableType => typeof(DoubleRange); 40 43 44 public override bool CanConvertType(Type t) => 45 ConvertableType.IsAssignableFrom(t); 46 41 47 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 42 48 DoubleRange range = item as DoubleRange; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeArrayConverter.cs
r17477 r17828 13 13 public override int Priority => 1; 14 14 public override Type ConvertableType => typeof(IntArray); 15 16 public override bool CanConvertType(Type t) => 17 ConvertableType.IsAssignableFrom(t); 15 18 16 19 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { … … 39 42 public override Type ConvertableType => typeof(DoubleArray); 40 43 44 public override bool CanConvertType(Type t) => 45 ConvertableType.IsAssignableFrom(t); 46 41 47 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 42 48 DoubleArray arr = item as DoubleArray; … … 63 69 public override int Priority => 2; 64 70 public override Type ConvertableType => typeof(PercentArray); 71 72 public override bool CanConvertType(Type t) => 73 ConvertableType.IsAssignableFrom(t); 65 74 66 75 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { … … 89 98 public override Type ConvertableType => typeof(BoolArray); 90 99 100 public override bool CanConvertType(Type t) => 101 ConvertableType.IsAssignableFrom(t); 102 91 103 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 92 104 BoolArray arr = item as BoolArray; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeMatrixConverter.cs
r17483 r17828 12 12 public override int Priority => 1; 13 13 public override Type ConvertableType => typeof(IntMatrix); 14 14 15 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) { 15 16 IntMatrix mat = item as IntMatrix; … … 92 93 where T : struct 93 94 { 95 public override bool CanConvertType(Type t) => 96 ConvertableType.IsAssignableFrom(t); 97 94 98 #region Helper 99 /// <summary> 100 /// Copies the data into the matrix object. Uses reflection to set the 101 /// row and column size of the matrix, because it is not possible to 102 /// create a new matrix at this point and there exists no public resize method. 103 /// </summary> 104 /// <param name="matrix"></param> 105 /// <param name="data"></param> 95 106 protected void CopyMatrixData(MatrixType matrix, T[][] data) { 96 107 var cols = data.Length; -
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeValueConverter.cs
r17483 r17828 12 12 public override int Priority => 1; 13 13 public override Type ConvertableType => typeof(IntValue); 14 15 public override bool CanConvertType(Type t) => 16 ConvertableType.IsAssignableFrom(t); 14 17 15 18 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => … … 30 33 public override Type ConvertableType => typeof(DoubleValue); 31 34 35 public override bool CanConvertType(Type t) => 36 ConvertableType.IsAssignableFrom(t); 37 32 38 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 33 39 ((DoubleValue)item).Value = ((DoubleJsonItem)data).Value; … … 46 52 public override int Priority => 2; 47 53 public override Type ConvertableType => typeof(PercentValue); 54 55 public override bool CanConvertType(Type t) => 56 ConvertableType.IsAssignableFrom(t); 48 57 49 58 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => … … 64 73 public override Type ConvertableType => typeof(BoolValue); 65 74 75 public override bool CanConvertType(Type t) => 76 ConvertableType.IsAssignableFrom(t); 77 66 78 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 67 79 ((BoolValue)item).Value = ((BoolJsonItem)data).Value; … … 79 91 public override Type ConvertableType => typeof(DateTimeValue); 80 92 93 public override bool CanConvertType(Type t) => 94 ConvertableType.IsAssignableFrom(t); 95 81 96 public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) => 82 97 ((DateTimeValue)item).Value = ((DateTimeJsonItem)data).Value;
Note: See TracChangeset
for help on using the changeset viewer.