Last change
on this file was
18077,
checked in by dpiringe, 3 years ago
|
#3026
- added the dockerhub readme file
- fixed a bug which caused changed values (changed by events) to be overwritten with wrong values
|
File size:
1.3 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Linq;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.JsonInterface {
|
---|
6 | public class ValueLookupParameterConverter : BaseConverter {
|
---|
7 | public override int Priority => 4;
|
---|
8 |
|
---|
9 | public override bool CanConvertType(Type t) =>
|
---|
10 | t.GetInterfaces().Any(x => x == typeof(IValueLookupParameter));
|
---|
11 |
|
---|
12 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
13 | IValueLookupParameter param = item as IValueLookupParameter;
|
---|
14 | IValueLookupJsonItem lookupItem = data as IValueLookupJsonItem;
|
---|
15 | if(data.Active)
|
---|
16 | param.ActualName = lookupItem.ActualName;
|
---|
17 | if (param.Value != null && lookupItem.ActualValue != null)
|
---|
18 | root.Inject(param.Value, lookupItem.ActualValue, root);
|
---|
19 | }
|
---|
20 |
|
---|
21 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
22 | IValueLookupParameter param = value as IValueLookupParameter;
|
---|
23 | IValueLookupJsonItem item = new ValueLookupJsonItem();
|
---|
24 |
|
---|
25 | if (param.Value != null) {
|
---|
26 | IJsonItem tmp = root.Extract(param.Value, root);
|
---|
27 | tmp.Parent = item;
|
---|
28 | item.ActualValue = tmp;
|
---|
29 | }
|
---|
30 | item.Name = param.Name;
|
---|
31 | item.Description = param.Description;
|
---|
32 | item.ActualName = param.ActualName;
|
---|
33 | return item;
|
---|
34 | }
|
---|
35 | }
|
---|
36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.