Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17712 was 17483, checked in by dpiringe, 5 years ago

#3026:

  • added readme JsonInterfaceReadMe.txt
  • removed dead code
  • fixed a bug in JsonItemConverter -> now the type comparison should work as intended
File size: 1.3 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;
[17473]15      IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem;
16      param.ActualName = lookupItem.ActualName;
[17477]17      if (param.Value != null && lookupItem.ActualValue != null)
18        root.Inject(param.Value, lookupItem.ActualValue, root);
[17407]19    }
20
21    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
[17394]22      IValueLookupParameter param = value as IValueLookupParameter;
23
[17483]24      IValueLookupJsonItem item = new ValueLookupJsonItem();
[17407]25
26      if (param.Value != null) {
[17406]27        IJsonItem tmp = root.Extract(param.Value, root);
[17477]28        tmp.Parent = item;
29        item.ActualValue = tmp;
[17342]30      }
[17420]31      item.Name = param.Name;
[17433]32      item.Description = param.Description;
[17420]33      item.ActualName = param.ActualName;
[17407]34      return item;
[17287]35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.