Last change
on this file since 17828 was
17828,
checked in by dpiringe, 3 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
|
Rev | Line | |
---|
[17287] | 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 {
|
---|
[17407] | 9 | public class ValueLookupParameterConverter : BaseConverter {
|
---|
[17394] | 10 | public override int Priority => 4;
|
---|
| 11 | public override Type ConvertableType => typeof(IValueLookupParameter);
|
---|
| 12 |
|
---|
[17828] | 13 | public override bool CanConvertType(Type t) =>
|
---|
| 14 | t.GetInterfaces().Any(x => x == typeof(IValueLookupParameter));
|
---|
| 15 |
|
---|
[17407] | 16 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
| 17 | IValueLookupParameter param = item as IValueLookupParameter;
|
---|
[17473] | 18 | IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem;
|
---|
| 19 | param.ActualName = lookupItem.ActualName;
|
---|
[17477] | 20 | if (param.Value != null && lookupItem.ActualValue != null)
|
---|
| 21 | root.Inject(param.Value, lookupItem.ActualValue, root);
|
---|
[17407] | 22 | }
|
---|
| 23 |
|
---|
| 24 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
[17394] | 25 | IValueLookupParameter param = value as IValueLookupParameter;
|
---|
| 26 |
|
---|
[17483] | 27 | IValueLookupJsonItem item = new ValueLookupJsonItem();
|
---|
[17407] | 28 |
|
---|
| 29 | if (param.Value != null) {
|
---|
[17406] | 30 | IJsonItem tmp = root.Extract(param.Value, root);
|
---|
[17477] | 31 | tmp.Parent = item;
|
---|
| 32 | item.ActualValue = tmp;
|
---|
[17342] | 33 | }
|
---|
[17420] | 34 | item.Name = param.Name;
|
---|
[17433] | 35 | item.Description = param.Description;
|
---|
[17420] | 36 | item.ActualName = param.ActualName;
|
---|
[17407] | 37 | return item;
|
---|
[17287] | 38 | }
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.