Last change
on this file since 17530 was
17519,
checked in by dpiringe, 5 years ago
|
#3026:
- added error output for failed runner initialization
- reorganised some final view models
- TargetedJsonItemType (in JsonItemVMBase) now automatically returns the type of the defined JsonItem
- code cleanup
- refactored RegressionProblemDataConverter
- added lots of comments
- added new view for StringArrayJsonItem
- added new UI component for concrete restricted items and used it in JsonItemConcreteItemArrayControl and JsonItemValidValuesControl
|
File size:
1.1 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using Newtonsoft.Json.Linq;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.JsonInterface {
|
---|
6 | public abstract class IntervalRestrictedArrayJsonItem<T> : ArrayJsonItem<T>, IIntervalRestrictedJsonItem<T>
|
---|
7 | where T : IComparable {
|
---|
8 | public T Minimum { get; set; }
|
---|
9 | public T Maximum { get; set; }
|
---|
10 |
|
---|
11 | protected override ValidationResult Validate() {
|
---|
12 | IList<string> errors = new List<string>();
|
---|
13 | bool success = true;
|
---|
14 | foreach (var x in Value) {
|
---|
15 | if (Minimum.CompareTo(x) > 0 && Maximum.CompareTo(x) < 0) {
|
---|
16 | success = false;
|
---|
17 | errors.Add($"[{Path}]: Value {x} is not between {Minimum} and {Maximum}.");
|
---|
18 | }
|
---|
19 | }
|
---|
20 | return new ValidationResult(success, errors);
|
---|
21 | }
|
---|
22 |
|
---|
23 | public override void SetJObject(JObject jObject) {
|
---|
24 | base.SetJObject(jObject);
|
---|
25 |
|
---|
26 | var minProp = jObject[nameof(IIntervalRestrictedJsonItem<T>.Minimum)];
|
---|
27 | if (minProp != null) Minimum = minProp.ToObject<T>();
|
---|
28 |
|
---|
29 |
|
---|
30 | var maxProp = jObject[nameof(IIntervalRestrictedJsonItem<T>.Maximum)];
|
---|
31 | if (maxProp != null) Maximum = maxProp.ToObject<T>();
|
---|
32 | }
|
---|
33 | }
|
---|
34 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.