Last change
on this file since 17828 was
17828,
checked in by dpiringe, 4 years ago
|
#3026
- removed the option to set the value for JsonItems via exporter
- reworked some base controls
- added new controls for JsonItem specific properties (e.g. ArrayResizable)
- deleted a lot of obsolet controls
- removed the Enable checkbox in the detail view of JsonItems
- exporter now clones the IOptimizer object
- added a check + message for unsupported exports
- list of JsonItems now includes unsupported JsonItems (disabled and marked with 'unsupported')
- refactored the converter type check
- now every converter has to specify its supported type(s)
|
File size:
1.4 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 | public override Type ConvertableType => typeof(IValueLookupParameter);
|
---|
12 |
|
---|
13 | public override bool CanConvertType(Type t) =>
|
---|
14 | t.GetInterfaces().Any(x => x == typeof(IValueLookupParameter));
|
---|
15 |
|
---|
16 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
17 | IValueLookupParameter param = item as IValueLookupParameter;
|
---|
18 | IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem;
|
---|
19 | param.ActualName = lookupItem.ActualName;
|
---|
20 | if (param.Value != null && lookupItem.ActualValue != null)
|
---|
21 | root.Inject(param.Value, lookupItem.ActualValue, root);
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
25 | IValueLookupParameter param = value as IValueLookupParameter;
|
---|
26 |
|
---|
27 | IValueLookupJsonItem item = new ValueLookupJsonItem();
|
---|
28 |
|
---|
29 | if (param.Value != null) {
|
---|
30 | IJsonItem tmp = root.Extract(param.Value, root);
|
---|
31 | tmp.Parent = item;
|
---|
32 | item.ActualValue = tmp;
|
---|
33 | }
|
---|
34 | item.Name = param.Name;
|
---|
35 | item.Description = param.Description;
|
---|
36 | item.ActualName = param.ActualName;
|
---|
37 | return item;
|
---|
38 | }
|
---|
39 | }
|
---|
40 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.