Last change
on this file since 17464 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
|
Rev | Line | |
---|
[17410] | 1 | using System;
|
---|
[17417] | 2 | using System.Collections;
|
---|
[17410] | 3 | using System.Collections.Generic;
|
---|
| 4 | using System.Linq;
|
---|
| 5 | using System.Text;
|
---|
| 6 | using System.Threading.Tasks;
|
---|
[17417] | 7 | using Newtonsoft.Json.Linq;
|
---|
[17410] | 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 {
|
---|
[17431] | 15 | get => ConvertObject(base.Value);
|
---|
[17410] | 16 | set => base.Value = value;
|
---|
| 17 | }
|
---|
[17431] | 18 |
|
---|
[17410] | 19 | public new IEnumerable<R> Range {
|
---|
[17417] | 20 | get => base.Range?.Cast<R>();
|
---|
[17410] | 21 | set => base.Range = value.Cast<object>();
|
---|
| 22 | }
|
---|
[17431] | 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 | }
|
---|
[17410] | 33 | }
|
---|
| 34 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.