Last change
on this file since 17712 was
17473,
checked in by dpiringe, 5 years ago
|
#3026:
- refactored inheritance structure of json items, now the default JsonItem is an abstract class without properties Value and Range -> splitted up into new interfaces
- updated view models for new json item structure
- updated SingleLineArrayJsonWriter
|
File size:
1.3 KB
|
Rev | Line | |
---|
[17269] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
[17284] | 4 | using System.Text;
|
---|
[17269] | 5 | using System.Threading.Tasks;
|
---|
| 6 | using HeuristicLab.Core;
|
---|
| 7 |
|
---|
[17284] | 8 | namespace HeuristicLab.JsonInterface {
|
---|
[17281] | 9 | public class ParameterizedItemConverter : BaseConverter {
|
---|
[17394] | 10 | public override int Priority => 2;
|
---|
| 11 | public override Type ConvertableType => typeof(IParameterizedItem);
|
---|
[17269] | 12 |
|
---|
[17407] | 13 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
[17394] | 14 | IParameterizedItem pItem = item as IParameterizedItem;
|
---|
| 15 |
|
---|
[17379] | 16 | if(data.Children != null) {
|
---|
| 17 | foreach (var sp in data.Children)
|
---|
[17410] | 18 | if (pItem.Parameters.TryGetValue(sp.Name, out IParameter param) && param != null)
|
---|
[17394] | 19 | root.Inject(param, sp, root);
|
---|
[17275] | 20 | }
|
---|
[17269] | 21 | }
|
---|
| 22 |
|
---|
[17407] | 23 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
[17433] | 24 | var parameterizedItem = value as IParameterizedItem;
|
---|
[17407] | 25 |
|
---|
[17473] | 26 | IJsonItem item = new EmptyJsonItem() {
|
---|
[17433] | 27 | Name = value.ItemName,
|
---|
| 28 | Description = value.ItemDescription
|
---|
| 29 | };
|
---|
| 30 |
|
---|
[17374] | 31 | foreach (var param in parameterizedItem.Parameters) {
|
---|
[17404] | 32 | if (!param.Hidden) {
|
---|
[17406] | 33 | IJsonItem tmp = root.Extract(param, root);
|
---|
[17407] | 34 | if (!(tmp is UnsupportedJsonItem))
|
---|
[17420] | 35 | item.AddChildren(tmp);
|
---|
[17404] | 36 | }
|
---|
[17269] | 37 | }
|
---|
[17407] | 38 |
|
---|
| 39 | return item;
|
---|
[17269] | 40 | }
|
---|
| 41 | }
|
---|
| 42 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.