Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/21 14:37:18 (4 years ago)
Author:
dpiringe
Message:

#3026

  • removed the option to set the value for JsonItems via exporter
    • reworked some base controls
    • added new controls for JsonItem specific properties (e.g. ArrayResizable)
    • deleted a lot of obsolet controls
  • removed the Enable checkbox in the detail view of JsonItems
  • exporter now clones the IOptimizer object
  • added a check + message for unsupported exports
  • list of JsonItems now includes unsupported JsonItems (disabled and marked with 'unsupported')
  • refactored the converter type check
    • now every converter has to specify its supported type(s)
Location:
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs

    r17451 r17828  
    1212
    1313    public override Type ConvertableType => typeof(IAlgorithm);
     14
     15    public override bool CanConvertType(Type t) =>
     16      t.GetInterfaces().Any(x => x == ConvertableType);
    1417
    1518    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BaseConverter.cs

    r17477 r17828  
    1212  {
    1313    public abstract int Priority { get; }
     14
     15    public abstract bool CanConvertType(Type t);
     16
    1417    public abstract Type ConvertableType { get; }
    1518
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/BatchRunConverter.cs

    r17540 r17828  
    1010    public override int Priority => 10;
    1111    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);
    1214
    1315    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
     
    3133        Maximum = int.MaxValue
    3234      });
    33      
    3435      return batchRunJI;
    3536    }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ConstrainedValueParameterConverter.cs

    r17485 r17828  
    1111    public override int Priority => 3;
    1212    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<>));
    1316
    1417    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/EnumTypeConverter.cs

    r17473 r17828  
    1111    public override int Priority => 1;
    1212    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);
    1317
    1418    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
     
    2529        Value = Enum.GetName(enumType, val),
    2630        ConcreteRestrictedItems = Enum.GetNames(enumType)
    27     };
     31      };
    2832    }
    2933  }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ExperimentConverter.cs

    r17540 r17828  
    1111    public override int Priority => 10;
    1212    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);
    1316
    1417    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/LookupParameterConverter.cs

    r17471 r17828  
    1010    public override int Priority => 3;
    1111    public override Type ConvertableType => typeof(ILookupParameter);
    12    
     12
     13    public override bool CanConvertType(Type t) =>
     14      t.GetInterfaces().Any(x => x == typeof(ILookupParameter));
     15
    1316    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
    1417      ((ILookupParameter)item).ActualName = ((ILookupJsonItem)data).ActualName as string;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/MultiCheckedOperatorConverter.cs

    r17484 r17828  
    1010  public class MultiCheckedOperatorConverter : ParameterizedItemConverter {
    1111    public override int Priority => 3;
     12
    1213    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
    1418    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    1519      base.Inject(item, data, root);
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ParameterizedItemConverter.cs

    r17473 r17828  
    1010    public override int Priority => 2;
    1111    public override Type ConvertableType => typeof(IParameterizedItem);
     12
     13    public override bool CanConvertType(Type t) =>
     14      t.GetInterfaces().Any(x => x == typeof(IParameterizedItem));
    1215
    1316    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
     
    3942      return item;
    4043    }
     44
    4145  }
    4246}
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/RegressionProblemDataConverter.cs

    r17560 r17828  
    3434    public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("EE612297-B1AF-42D2-BF21-AF9A2D42791C"));
    3535
     36    public override bool CanConvertType(Type t) =>
     37      ConvertableType.IsAssignableFrom(t);
     38
    3639    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    3740
     
    180183        if(it != null) {
    181184          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);
    183186            return new DoubleMatrixJsonItem() {
    184187              Name = Dataset,
    185188              Value = mat,
    186               RowNames = rowNames,
     189              ColumnNames = columnNames,
    187190              Minimum = double.MinValue,
    188191              Maximum = double.MaxValue
    189192            };
    190193          } 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);
    192195            return new IntMatrixJsonItem() {
    193196              Name = Dataset,
    194197              Value = mat,
    195               RowNames = rowNames,
     198              ColumnNames = columnNames,
    196199              Minimum = int.MinValue,
    197200              Maximum = int.MaxValue
    198201            };
    199202          } 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);
    201204            return new BoolMatrixJsonItem() {
    202205              Name = Dataset,
    203206              Value = mat,
    204               RowNames = rowNames
     207              ColumnNames = columnNames
    205208            };
    206209          }
     
    210213    }
    211214   
    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) {
    213216      int cols = dict.Count, rows = 0, c = 0;
    214       rowNames = new List<string>();
     217      columnNames = new List<string>();
    215218      matrix = new T[cols][];
    216219      foreach (var x in dict) {
    217220        rows = Math.Max(rows, x.Value.Count);
    218         rowNames.Add(x.Key);
     221        columnNames.Add(x.Key);
    219222
    220223        matrix[c] = new T[rows];
     224
    221225        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;
    225228          ++r;
    226229        }
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultParameterConverter.cs

    r17473 r17828  
    1212
    1313    public override Type ConvertableType => typeof(IResultParameter);
     14
     15    public override bool CanConvertType(Type t) =>
     16      t.GetInterfaces().Any(x => x == typeof(IResultParameter));
    1417
    1518    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/StringValueConverter.cs

    r17483 r17828  
    1212    public override Type ConvertableType => typeof(StringValue);
    1313
     14    public override bool CanConvertType(Type t) =>
     15      ConvertableType.IsAssignableFrom(t);
     16
    1417    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
    1518      ((StringValue)item).Value = ((StringJsonItem)data).Value;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs

    r17483 r17828  
    1010    public override int Priority => 4;
    1111    public override Type ConvertableType => typeof(IValueLookupParameter);
     12
     13    public override bool CanConvertType(Type t) =>
     14      t.GetInterfaces().Any(x => x == typeof(IValueLookupParameter));
    1215
    1316    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueParameterConverter.cs

    r17519 r17828  
    1010    public override int Priority => 2;
    1111    public override Type ConvertableType => typeof(IValueParameter);
     12
     13    public override bool CanConvertType(Type t) =>
     14      t.GetInterfaces().Any(x => x == typeof(IValueParameter));
    1215
    1316    public override void Inject(IItem value, IJsonItem data, IJsonItemConverter root) {
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueRangeConverter.cs

    r17483 r17828  
    1414    public override int Priority => 1;
    1515    public override Type ConvertableType => typeof(IntRange);
     16
     17    public override bool CanConvertType(Type t) =>
     18      ConvertableType.IsAssignableFrom(t);
    1619
    1720    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
     
    3942    public override Type ConvertableType => typeof(DoubleRange);
    4043
     44    public override bool CanConvertType(Type t) =>
     45      ConvertableType.IsAssignableFrom(t);
     46
    4147    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    4248      DoubleRange range = item as DoubleRange;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeArrayConverter.cs

    r17477 r17828  
    1313    public override int Priority => 1;
    1414    public override Type ConvertableType => typeof(IntArray);
     15
     16    public override bool CanConvertType(Type t) =>
     17      ConvertableType.IsAssignableFrom(t);
    1518
    1619    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
     
    3942    public override Type ConvertableType => typeof(DoubleArray);
    4043
     44    public override bool CanConvertType(Type t) =>
     45      ConvertableType.IsAssignableFrom(t);
     46
    4147    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    4248      DoubleArray arr = item as DoubleArray;
     
    6369    public override int Priority => 2;
    6470    public override Type ConvertableType => typeof(PercentArray);
     71
     72    public override bool CanConvertType(Type t) =>
     73      ConvertableType.IsAssignableFrom(t);
    6574
    6675    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
     
    8998    public override Type ConvertableType => typeof(BoolArray);
    9099
     100    public override bool CanConvertType(Type t) =>
     101      ConvertableType.IsAssignableFrom(t);
     102
    91103    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    92104      BoolArray arr = item as BoolArray;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeMatrixConverter.cs

    r17483 r17828  
    1212    public override int Priority => 1;
    1313    public override Type ConvertableType => typeof(IntMatrix);
     14
    1415    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
    1516      IntMatrix mat = item as IntMatrix;
     
    9293    where T : struct
    9394  {
     95    public override bool CanConvertType(Type t) =>
     96      ConvertableType.IsAssignableFrom(t);
     97
    9498    #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>
    95106    protected void CopyMatrixData(MatrixType matrix, T[][] data) {
    96107      var cols = data.Length;
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueTypeValueConverter.cs

    r17483 r17828  
    1212    public override int Priority => 1;
    1313    public override Type ConvertableType => typeof(IntValue);
     14
     15    public override bool CanConvertType(Type t) =>
     16      ConvertableType.IsAssignableFrom(t);
    1417
    1518    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
     
    3033    public override Type ConvertableType => typeof(DoubleValue);
    3134
     35    public override bool CanConvertType(Type t) =>
     36      ConvertableType.IsAssignableFrom(t);
     37
    3238    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
    3339      ((DoubleValue)item).Value = ((DoubleJsonItem)data).Value;
     
    4652    public override int Priority => 2;
    4753    public override Type ConvertableType => typeof(PercentValue);
     54
     55    public override bool CanConvertType(Type t) =>
     56      ConvertableType.IsAssignableFrom(t);
    4857
    4958    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
     
    6473    public override Type ConvertableType => typeof(BoolValue);
    6574
     75    public override bool CanConvertType(Type t) =>
     76      ConvertableType.IsAssignableFrom(t);
     77
    6678    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
    6779      ((BoolValue)item).Value = ((BoolJsonItem)data).Value;
     
    7991    public override Type ConvertableType => typeof(DateTimeValue);
    8092
     93    public override bool CanConvertType(Type t) =>
     94      ConvertableType.IsAssignableFrom(t);
     95
    8196    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
    8297      ((DateTimeValue)item).Value = ((DateTimeJsonItem)data).Value;
Note: See TracChangeset for help on using the changeset viewer.