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

Last change on this file since 17843 was 17843, checked in by dpiringe, 7 weeks ago

#3026

  • removed property ConvertableType from all converters
  • removed the option to fixate or loosen the path of JsonItems (obsolete)
  • added a abstract formatter SymbolicRegressionSolutionFormatterBase as base formatter for ISymbolicRegressionSolution
  • unified the construction of exporter controls
  • code cleanup
File size: 960 bytes
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
12    public override bool CanConvertType(Type t) =>
13      t.GetInterfaces().Any(x => x == typeof(ILookupParameter));
14
15    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) =>
16      ((ILookupParameter)item).ActualName = ((ILookupJsonItem)data).ActualName as string;
17
18    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
19      IParameter parameter = value as IParameter;
20
21      IJsonItem item = new LookupJsonItem() {
22        Name = parameter.Name,
23        Description = parameter.Description,
24        ActualName = ((ILookupParameter)parameter).ActualName
25      };
26      return item;
27    }
28  }
29}
Note: See TracBrowser for help on using the repository browser.