Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ResultConverter.cs @ 18039

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