Free cookie consent management tool by TermsFeed Policy Generator

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

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

#3026:

  • refactored inheritance structure of json items, now the default JsonItem is an abstract class without properties Value and Range -> splitted up into new interfaces
  • updated view models for new json item structure
  • updated SingleLineArrayJsonWriter
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)
18        root.Inject(param.Value, lookupItem.JsonItemReference, 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        item.AddChildren(tmp.Children);
29        item.JsonItemReference = 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.