source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/LookupParameterConverter.cs @ 17828

Last change on this file since 17828 was 17828, checked in by dpiringe, 2 months ago

#3026

  • removed the option to set the value for JsonItems via exporter
    • reworked some base controls
    • added new controls for JsonItem specific properties (e.g. ArrayResizable)
    • deleted a lot of obsolet controls
  • removed the Enable checkbox in the detail view of JsonItems
  • exporter now clones the IOptimizer object
  • added a check + message for unsupported exports
  • list of JsonItems now includes unsupported JsonItems (disabled and marked with 'unsupported')
  • refactored the converter type check
    • now every converter has to specify its supported type(s)
File size: 1.0 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 LookupParameterConverter : BaseConverter {
10    public override int Priority => 3;
11    public override Type ConvertableType => typeof(ILookupParameter);
12
13    public override bool CanConvertType(Type t) =>
14      t.GetInterfaces().Any(x => x == typeof(ILookupParameter));
15
16    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
17      ((ILookupParameter)item).ActualName = ((ILookupJsonItem)data).ActualName as string;
18
19    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
20      IParameter parameter = value as IParameter;
21
22      IJsonItem item = new LookupJsonItem() {
23        Name = parameter.Name,
24        Description = parameter.Description,
25        ActualName = ((ILookupParameter)parameter).ActualName
26      };
27      return item;
28    }
29  }
30}
Note: See TracBrowser for help on using the repository browser.