Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Converters/ValueLookupParameterConverter.cs @ 17342

Last change on this file since 17342 was 17342, checked in by dpiringe, 4 years ago

#3026

  • in JsonItem:
    • renamed property Default to Value
    • removed usage of Reference for ValueLookupParameter
    • created new property ActualName for the actual name and using property Value for the value of an ValueLookupParameter
  • fixed a bug in ValueTypeMatrixConverter -> now it correctly resizes ValueTypeMatrix<T>
  • fixed a bug in ValueParameterConverter -> when ActualValue is null, but there is data for it, a new instance will get created
File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Core;
7
8namespace HeuristicLab.JsonInterface {
9  public class ValueLookupParameterConverter : ParameterBaseConverter {
10    public override JsonItem ExtractData(IParameter value) {
11      IValueLookupParameter param = value.Cast<IValueLookupParameter>();
12      object actualValue = null;
13      IList<object> actualRange = null;
14      if(param.Value != null) {
15        JsonItem tmp = JsonItemConverter.Extract(param.Value);
16        actualValue = tmp.Value;
17        actualRange = tmp.Range;
18      }
19      return new JsonItem() {
20        Name = value.Name,
21        ActualName = param.ActualName,
22        Value = actualValue,
23        Range = actualRange
24      };
25    }
26
27    public override void InjectData(IParameter parameter, JsonItem data) {
28      IValueLookupParameter param = parameter.Cast<IValueLookupParameter>();
29      param.ActualName = CastValue<string>(data.ActualName);
30      if (param.Value != null)
31        JsonItemConverter.Inject(param.Value, data);
32    }
33  }
34}
Note: See TracBrowser for help on using the repository browser.