Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs @ 17464

Last change on this file since 17464 was 17451, checked in by dpiringe, 4 years ago

#3026:

  • renamed ResultItem to ResultJsonItem
  • implemented RegressionProblemDataConverter
  • added support for "named matrices" (named = rows and columns have names) -> INamedMatrixJsonItem incl. base classes and views
  • added a bool property Active in IJsonItem -> marks items, which should be written into the template
File size: 1.4 KB
RevLine 
[17287]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Core;
7
8namespace HeuristicLab.JsonInterface {
[17407]9  public class ValueLookupParameterConverter : BaseConverter {
[17394]10    public override int Priority => 4;
11    public override Type ConvertableType => typeof(IValueLookupParameter);
12
[17407]13    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
14      IValueLookupParameter param = item as IValueLookupParameter;
15      param.ActualName = CastValue<string>(data.ActualName);
16      if (param.Value != null)
17        root.Inject(param.Value, data, root);
18    }
19
20    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
[17394]21      IValueLookupParameter param = value as IValueLookupParameter;
22
[17420]23      IJsonItem item = new JsonItem() {};
[17407]24
25      if (param.Value != null) {
[17406]26        IJsonItem tmp = root.Extract(param.Value, root);
[17420]27        item = tmp;
[17379]28      } else {
[17451]29        var min = GetMinValue(param.DataType);
30        var max = GetMaxValue(param.DataType);
31        if (min != null && max != null)
32          item.Range = new object[] { min, max };
33        else
34          item.Range = null;
[17342]35      }
[17420]36      item.Name = param.Name;
[17433]37      item.Description = param.Description;
[17420]38      item.ActualName = param.ActualName;
[17407]39      return item;
[17287]40    }
41  }
42}
Note: See TracBrowser for help on using the repository browser.