Last change
on this file since 17417 was
17410,
checked in by dpiringe, 5 years ago
|
#3026:
- deleted JsonItemArrayControl and JsonItemDefaultControl
- redesigned architecture for JsonItem: now there are different types of JsonItem (IntJsonItem, BoolJsonItem, ...) -> for better type safety and expandability
- fixed bug in BaseConverter for GetMinValue and GetMaxValue for IntValue, but ignored for other value types (DoubleValue, DateTimeValue, ...) because the redesign of JsonItem-Architecture can make these two methods obsolet soon
- fixed bug in JsonItemConverter to prevent null pointer exceptions
- refactored value and range converters -> removed complicated generic ValueTypeValueConverter and ValueRangeConverter and implemented the necessary methods directly in concrete classes (improves readability and removes the need of reflection)
- redesigned view handling in OptimizerIntegration -> dynamically seaches for JsonItemVMBase implementations, which are connected with a view
- this enables better scaling with more user controls
- JsonItemVMBase implements MVVM architecture
|
File size:
1.3 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 : BaseConverter {
|
---|
10 | public override int Priority => 2;
|
---|
11 | public override Type ConvertableType => typeof(IValueParameter);
|
---|
12 |
|
---|
13 | public override void Inject(IItem value, IJsonItem data, IJsonItemConverter root) {
|
---|
14 | IParameter parameter = value as IParameter;
|
---|
15 |
|
---|
16 | if (parameter.ActualValue == null && data.Value != null)
|
---|
17 | parameter.ActualValue = Instantiate(parameter.DataType);
|
---|
18 | root.Inject(parameter.ActualValue, data, root);
|
---|
19 | }
|
---|
20 |
|
---|
21 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
22 | IParameter parameter = value as IParameter;
|
---|
23 |
|
---|
24 | IJsonItem item = new JsonItem() {
|
---|
25 | Name = parameter.Name
|
---|
26 | };
|
---|
27 |
|
---|
28 | if (parameter.ActualValue != null) {
|
---|
29 | IJsonItem tmp = root.Extract(parameter.ActualValue, root);
|
---|
30 | if (!(tmp is UnsupportedJsonItem)) {
|
---|
31 | if (tmp.Name == "[OverridableParamName]") {
|
---|
32 | tmp.Name = parameter.Name;
|
---|
33 | item = tmp;
|
---|
34 | //JsonItem.Merge(item as JsonItem, tmp as JsonItem);
|
---|
35 | } else
|
---|
36 | item.AddChilds(tmp);
|
---|
37 | }
|
---|
38 | }
|
---|
39 | return item;
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.