Last change
on this file since 17399 was
17395,
checked in by dpiringe, 5 years ago
|
#3026:
- moved from usage of IAlgorithm to IOptimizer (in JCGenerator and JsonTemplateInstantiator)
- added new converter: AlgorithmConverter
|
File size:
1022 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Optimization;
|
---|
8 |
|
---|
9 | namespace 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 | item.AddChilds(root.Extract(algorithm.Problem, root));
|
---|
27 | }
|
---|
28 | }
|
---|
29 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.