Last change
on this file since 17451 was
17431,
checked in by dpiringe, 5 years ago
|
#3026:
- renamed JsonItemArrayValueControl to JsonItemMultiValueControl
- extracted converter logic from property Value in JsonItem<V,R> into new private method ConvertObject
- added references to TreeNode and TreeView in JsonItemVMBase -> for additional user feedback when enabling/disabling an item (changes the fore color of referenced node)
- changed implementation and interplay between ArrayValueVM and JsonItemMultiValueControl -> removed the direct access of property DataSource of DataGridView -> now: dynamically adds new columns/rows and accesses grid cells manually (better handling with matrices)
- added new VM MatrixValueVM
|
File size:
805 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 => ConvertObject(base.Value);
|
---|
16 | set => base.Value = value;
|
---|
17 | }
|
---|
18 |
|
---|
19 | public new IEnumerable<R> Range {
|
---|
20 | get => base.Range?.Cast<R>();
|
---|
21 | set => base.Range = value.Cast<object>();
|
---|
22 | }
|
---|
23 |
|
---|
24 | private V ConvertObject(object obj) {
|
---|
25 | if (obj is IConvertible)
|
---|
26 | return (V)Convert.ChangeType(obj, typeof(V));
|
---|
27 |
|
---|
28 | if (obj is JToken token)
|
---|
29 | return token.ToObject<V>();
|
---|
30 |
|
---|
31 | return (V)obj;
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.