Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17843 was 17843, checked in by dpiringe, 3 years 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: 983 bytes
Line 
1using System;
2using System.Linq;
3using HeuristicLab.Core;
4using HeuristicLab.Optimization;
5
6namespace HeuristicLab.JsonInterface {
7  public class ResultParameterConverter : BaseConverter {
8    public override int Priority => 5;
9
10    public override bool CanConvertType(Type t) =>
11      t.GetInterfaces().Any(x => x == typeof(IResultParameter));
12
13    public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
14      IResultParameter res = value as IResultParameter;
15      var formatter = ResultFormatter.ForType(res.DataType).Last();
16      return new ResultJsonItem() {
17        Name = res.ActualName,
18        Description = res.Description,
19        ResultFormatterType = formatter.GetType().FullName,
20        ValueType = res.DataType
21      };
22    }
23
24    public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
25      IResultParameter res = item as IResultParameter;
26      res.ActualName = data.Name;
27    }
28  }
29}
Note: See TracBrowser for help on using the repository browser.