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:
1.3 KB
|
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 |
|
---|
8 | namespace HeuristicLab.JsonInterface {
|
---|
9 | public class ValueLookupParameterConverter : BaseConverter {
|
---|
10 | public override int Priority => 4;
|
---|
11 |
|
---|
12 | public override bool CanConvertType(Type t) =>
|
---|
13 | t.GetInterfaces().Any(x => x == typeof(IValueLookupParameter));
|
---|
14 |
|
---|
15 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
16 | IValueLookupParameter param = item as IValueLookupParameter;
|
---|
17 | IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem;
|
---|
18 | param.ActualName = lookupItem.ActualName;
|
---|
19 | if (param.Value != null && lookupItem.ActualValue != null)
|
---|
20 | root.Inject(param.Value, lookupItem.ActualValue, root);
|
---|
21 | }
|
---|
22 |
|
---|
23 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
24 | IValueLookupParameter param = value as IValueLookupParameter;
|
---|
25 |
|
---|
26 | IValueLookupJsonItem item = new ValueLookupJsonItem();
|
---|
27 |
|
---|
28 | if (param.Value != null) {
|
---|
29 | IJsonItem tmp = root.Extract(param.Value, root);
|
---|
30 | tmp.Parent = item;
|
---|
31 | item.ActualValue = tmp;
|
---|
32 | }
|
---|
33 | item.Name = param.Name;
|
---|
34 | item.Description = param.Description;
|
---|
35 | item.ActualName = param.ActualName;
|
---|
36 | return item;
|
---|
37 | }
|
---|
38 | }
|
---|
39 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.