Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/AlgorithmConverter.cs @ 17405

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

#3026:

  • added a new way to setup the targeted result types
  • added new ui controls: NumericRangeControl, JsonItemArrayControl, JsonItemDefaultControl
  • redesigned export dialog -> now the user can navigate with a tree view
  • enhanced JsonItemVM
File size: 1.2 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Core;
7using HeuristicLab.Optimization;
8
9namespace HeuristicLab.JsonInterface.Converters {
10  public class AlgorithmConverter : ParameterizedItemConverter {
11    public override int Priority => 30;
12
13    public override Type ConvertableType => typeof(IAlgorithm);
14
15    public override void InjectData(IItem item, JsonItem data, IJsonItemConverter root) {
16      base.InjectData(item, data, root);
17      IAlgorithm algorithm = item as IAlgorithm;
18      JsonItem problemData = data.Children.Where(x => x.Name == algorithm.Problem.Name).First();
19      root.Inject(algorithm.Problem, problemData, root);
20
21    }
22
23    public override void Populate(IItem value, JsonItem item, IJsonItemConverter root) {
24      base.Populate(value, item, root);
25      IAlgorithm algorithm = value as IAlgorithm;
26      foreach(var res in algorithm.Results) {
27        item.AddChilds(new ResultItem() {
28          Name = res.Name,
29          Value = true,
30          Range = new object[] { true, false }
31        });
32      }
33      item.AddChilds(root.Extract(algorithm.Problem, root));
34    }
35  }
36}
Note: See TracBrowser for help on using the repository browser.