Last change
on this file since 17405 was
17404,
checked in by dpiringe, 4 years ago
|
#3026:
- fixed a bug in BaseConverter -> the range for percent values should be returned correctly now
- fixed a bug in ConstrainedValueParameterConverter, ParameterizedItemConverter, ValueParameterConverter -> unsupported json items get filtered now
- JCGenerator is now a dynamic class and can return all JsonItems for an IOptimizer now (instead of string only) + it is now possible to generate an template string with an IEnumerable<JsonItem>
- added first version of an export dialog for JsonInterface
- it is organized with a main view (for the dialog) and some user controls (for a better visualization of an JsonItem -> to reduce wrong user inputs)
- the user controls inherit a base control, which organizes some base values of an JsonItem
|
File size:
1.1 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 ValueParameterConverter : ParameterBaseConverter {
|
---|
10 | public override int Priority => 2;
|
---|
11 | public override Type ConvertableType => typeof(IValueParameter);
|
---|
12 |
|
---|
13 | public override void InjectData(IParameter parameter, JsonItem data, IJsonItemConverter root) {
|
---|
14 | if (parameter.ActualValue == null && data.Value != null)
|
---|
15 | parameter.ActualValue = Instantiate(parameter.DataType);
|
---|
16 | root.Inject(parameter.ActualValue, data, root);
|
---|
17 | }
|
---|
18 |
|
---|
19 | public override void Populate(IParameter value, JsonItem item, IJsonItemConverter root) {
|
---|
20 | item.Name = value.Name;
|
---|
21 | if (value.ActualValue != null) {
|
---|
22 | JsonItem tmp = root.Extract(value.ActualValue, root);
|
---|
23 | if(!(tmp is UnsupportedJsonItem)) {
|
---|
24 | if (tmp.Name == "[OverridableParamName]") {
|
---|
25 | tmp.Name = value.Name;
|
---|
26 | JsonItem.Merge(item, tmp);
|
---|
27 | } else
|
---|
28 | item.AddChilds(tmp);
|
---|
29 | }
|
---|
30 | }
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.