Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/03/20 15:13:35 (4 years ago)
Author:
dpiringe
Message:

#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:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/GenericJsonItem.cs

    r17410 r17417  
    11using System;
     2using System.Collections;
    23using System.Collections.Generic;
    34using System.Linq;
    45using System.Text;
    56using System.Threading.Tasks;
     7using Newtonsoft.Json.Linq;
    68
    79namespace HeuristicLab.JsonInterface {
     
    1113  public class JsonItem<V,R> : JsonItem {
    1214    public new V Value {
    13       get => (V)Convert.ChangeType(base.Value, typeof(V));
     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      }
    1424      set => base.Value = value;
    1525    }
    1626
    1727    public new IEnumerable<R> Range {
    18       get => base.Range.Cast<R>();
     28      get => base.Range?.Cast<R>();
    1929      set => base.Range = value.Cast<object>();
    2030    }
Note: See TracChangeset for help on using the changeset viewer.