Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/IntervalRestrictedJsonItem.cs @ 18043

Last change on this file since 18043 was 18043, checked in by dpiringe, 3 years ago

#3026

  • code cleanup
File size: 676 bytes
Line 
1using System;
2using Newtonsoft.Json.Linq;
3
4namespace HeuristicLab.JsonInterface {
5  public abstract class IntervalRestrictedJsonItem<T> : JsonItem, IIntervalRestrictedJsonItem<T>
6    where T : IComparable {
7    public T Minimum { get; set; }
8    public T Maximum { get; set; }
9
10    public override void SetJObject(JObject jObject) {
11      base.SetJObject(jObject);
12
13      var minProp = jObject[nameof(IIntervalRestrictedJsonItem<T>.Minimum)];
14      if (minProp != null) Minimum = minProp.ToObject<T>();
15
16      var maxProp = jObject[nameof(IIntervalRestrictedJsonItem<T>.Maximum)];
17      if (maxProp != null) Maximum = maxProp.ToObject<T>();
18    }
19  }
20}
Note: See TracBrowser for help on using the repository browser.