Last change
on this file since 17417 was
17417,
checked in by dpiringe, 5 years ago
|
#3026:
- added initial VM (ArrayValueVM) and control for array values (JsonItemArrayValueControl)
- new types of JsonItems for better type safety:
- for arrays: DoubleArrayJsonItem, IntArrayJsonItem, BoolArrayJsonItem
- for matrix: DoubleMatrixJsonItem, IntMatrixJsonItem, BoolMatrixJsonItem
- refactored ValueTypeArrayConverter and ValueTypeMatrixConverter -> better type safety with new JsonItems
- enhanced StringValueVM and implemented JsonItemValidValuesControl with MVVM architecture
- the VM of JsonItemBaseControl is now protected (was private)
- improved JsonItem<V,R> -> now handles JTokens correctly
|
File size:
766 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 | using Newtonsoft.Json.Linq;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.JsonInterface {
|
---|
10 |
|
---|
11 | public class JsonItem<T> : JsonItem<T,T> { }
|
---|
12 |
|
---|
13 | public class JsonItem<V,R> : JsonItem {
|
---|
14 | public new V Value {
|
---|
15 | get {
|
---|
16 | if(base.Value is IConvertible)
|
---|
17 | return (V)Convert.ChangeType(base.Value, typeof(V));
|
---|
18 |
|
---|
19 | if(base.Value is JToken token)
|
---|
20 | return token.ToObject<V>();
|
---|
21 |
|
---|
22 | return (V)base.Value;
|
---|
23 | }
|
---|
24 | set => base.Value = value;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public new IEnumerable<R> Range {
|
---|
28 | get => base.Range?.Cast<R>();
|
---|
29 | set => base.Range = value.Cast<object>();
|
---|
30 | }
|
---|
31 | }
|
---|
32 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.