Last change
on this file since 17435 was
17435,
checked in by dpiringe, 4 years ago
|
#3026:
- set read-only to false for name input (in JsonItemBaseControl)
- result items now can be selected/deselected in export dialog
- removed metadata.problem property and renamed metadata.optimizer property to TemplateName in json template
- fixed bug with wrong description for result items in AlgorithmConverter
- refactored a lot of code in JCGenerator and added the need for a directory path (location for the template files)
- fixed a null reference bug in JsonItemValidator (cannot try to iterate through possible null referenced collections)
|
File size:
1.3 KB
|
Rev | Line | |
---|
[17395] | 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 |
|
---|
[17435] | 9 | namespace HeuristicLab.JsonInterface {
|
---|
[17395] | 10 | public class AlgorithmConverter : ParameterizedItemConverter {
|
---|
| 11 | public override int Priority => 30;
|
---|
| 12 |
|
---|
| 13 | public override Type ConvertableType => typeof(IAlgorithm);
|
---|
| 14 |
|
---|
[17407] | 15 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
| 16 | base.Inject(item, data, root);
|
---|
[17395] | 17 | IAlgorithm algorithm = item as IAlgorithm;
|
---|
[17406] | 18 | IJsonItem problemData = data.Children.Where(x => x.Name == algorithm.Problem.Name).First();
|
---|
[17395] | 19 | root.Inject(algorithm.Problem, problemData, root);
|
---|
| 20 |
|
---|
| 21 | }
|
---|
[17407] | 22 |
|
---|
| 23 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
| 24 | IJsonItem item = base.Extract(value, root);
|
---|
[17395] | 25 | IAlgorithm algorithm = value as IAlgorithm;
|
---|
[17407] | 26 | foreach (var res in algorithm.Results) {
|
---|
[17420] | 27 | item.AddChildren(new ResultItem() {
|
---|
[17407] | 28 | Name = res.Name,
|
---|
[17435] | 29 | Description = res.Description,
|
---|
[17407] | 30 | Value = true,
|
---|
| 31 | Range = new object[] { true, false }
|
---|
[17405] | 32 | });
|
---|
| 33 | }
|
---|
[17420] | 34 | item.AddChildren(root.Extract(algorithm.Problem, root));
|
---|
[17407] | 35 | return item;
|
---|
[17395] | 36 | }
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.