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
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      IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem;
16      param.ActualName = lookupItem.ActualName;
17      if (param.Value != null && lookupItem.ActualValue != null)
18        root.Inject(param.Value, lookupItem.ActualValue, root);
19    }
20
21    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
22      IValueLookupParameter param = value as IValueLookupParameter;
23
24      IValueLookupJsonItem item = new ValueLookupJsonItem();
25
26      if (param.Value != null) {
27        IJsonItem tmp = root.Extract(param.Value, root);
28        tmp.Parent = item;
29        item.ActualValue = tmp;
30      }
31      item.Name = param.Name;
32      item.Description = param.Description;
33      item.ActualName = param.ActualName;
34      return item;
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.