Last change
on this file since 17473 was
17473,
checked in by dpiringe, 4 years ago
|
#3026:
- refactored inheritance structure of json items, now the default JsonItem is an abstract class without properties Value and Range -> splitted up into new interfaces
- updated view models for new json item structure
- updated SingleLineArrayJsonWriter
|
File size:
902 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 | using Newtonsoft.Json.Linq;
|
---|
7 |
|
---|
8 | namespace HeuristicLab.JsonInterface {
|
---|
9 | public abstract class IntervalRestrictedArrayJsonItem<T> : ArrayJsonItem<T>, IIntervalRestrictedJsonItem<T>
|
---|
10 | where T : IComparable {
|
---|
11 | public T Minimum { get; set; }
|
---|
12 | public T Maximum { get; set; }
|
---|
13 |
|
---|
14 | protected override bool Validate() {
|
---|
15 | foreach(var x in Value) {
|
---|
16 | if (Minimum.CompareTo(x) > 0 || Maximum.CompareTo(x) < 0)
|
---|
17 | return false;
|
---|
18 | }
|
---|
19 | return true;
|
---|
20 | }
|
---|
21 |
|
---|
22 | public override void SetFromJObject(JObject jObject) {
|
---|
23 | base.SetFromJObject(jObject);
|
---|
24 | Minimum = jObject[nameof(IIntervalRestrictedJsonItem<T>.Minimum)].ToObject<T>();
|
---|
25 | Maximum = jObject[nameof(IIntervalRestrictedJsonItem<T>.Maximum)].ToObject<T>();
|
---|
26 | }
|
---|
27 | }
|
---|
28 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.