Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3026:

  • refactored ranged based VMs -> created new 'base' class for ranged based VMs RangedValueBaseVM
  • renamed AddChilds to AddChildren
  • implemented ArrayValueVM and JsonItemArrayValueControl
  • added ranges for array and matrix values
File size: 1.3 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        /*tmp.Parent = item;
28        actualValue = tmp.Value;
29        actualRange = tmp.Range;
30        */
31        item = tmp;
32      } else {
33        item.Range = new object[] { GetMinValue(param.DataType), GetMaxValue(param.DataType) };
34      }
35      item.Name = param.Name;
36      item.ActualName = param.ActualName;
37      return item;
38    }
39  }
40}
Note: See TracBrowser for help on using the repository browser.