- Timestamp:
- 02/10/20 16:46:09 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/GenericJsonItem.cs
r17417 r17431 13 13 public class JsonItem<V,R> : JsonItem { 14 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 } 15 get => ConvertObject(base.Value); 24 16 set => base.Value = value; 25 17 } 26 18 27 19 public new IEnumerable<R> Range { 28 20 get => base.Range?.Cast<R>(); 29 21 set => base.Range = value.Cast<object>(); 30 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 } 31 33 } 32 34 }
Note: See TracChangeset
for help on using the changeset viewer.