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
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Core;
7
8namespace HeuristicLab.JsonInterface {
9  public class ValueLookupParameterConverter : BaseConverter {
10    public override int Priority => 4;
11    public override Type ConvertableType => typeof(IValueLookupParameter);
12
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) {
21      IValueLookupParameter param = value as IValueLookupParameter;
22
23      IJsonItem item = new JsonItem() {};
24
25      if (param.Value != null) {
26        IJsonItem tmp = root.Extract(param.Value, root);
27        item = tmp;
28      } else {
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;
35      }
36      item.Name = param.Name;
37      item.Description = param.Description;
38      item.ActualName = param.ActualName;
39      return item;
40    }
41  }
42}
Note: See TracBrowser for help on using the repository browser.