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:
1002 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using Newtonsoft.Json.Linq;
|
---|
3 |
|
---|
4 | namespace HeuristicLab.JsonInterface {
|
---|
5 | public abstract class IntervalRestrictedValueJsonItem<T> : ValueJsonItem<T>, IIntervalRestrictedJsonItem<T>
|
---|
6 | where T : IComparable {
|
---|
7 | public T Minimum { get; set; }
|
---|
8 | public T Maximum { get; set; }
|
---|
9 |
|
---|
10 | protected override ValidationResult Validate() {
|
---|
11 | bool res = Minimum.CompareTo(Value) <= 0 && Maximum.CompareTo(Value) >= 0;
|
---|
12 | if (res) return ValidationResult.Successful();
|
---|
13 | else return ValidationResult.Faulty($"[{Path}]: Value {Value} is not between {Minimum} and {Maximum}.");
|
---|
14 | }
|
---|
15 |
|
---|
16 | public override void SetJObject(JObject jObject) {
|
---|
17 | base.SetJObject(jObject);
|
---|
18 |
|
---|
19 | var minProp = jObject[nameof(IIntervalRestrictedJsonItem<T>.Minimum)];
|
---|
20 | if (minProp != null) Minimum = minProp.ToObject<T>();
|
---|
21 |
|
---|
22 |
|
---|
23 | var maxProp = jObject[nameof(IIntervalRestrictedJsonItem<T>.Maximum)];
|
---|
24 | if (maxProp != null) Maximum = maxProp.ToObject<T>();
|
---|
25 | }
|
---|
26 | }
|
---|
27 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.