Last change
on this file since 17828 was
17828,
checked in by dpiringe, 3 years ago
|
#3026
- removed the option to set the value for JsonItems via exporter
- reworked some base controls
- added new controls for JsonItem specific properties (e.g. ArrayResizable)
- deleted a lot of obsolet controls
- removed the Enable checkbox in the detail view of JsonItems
- exporter now clones the IOptimizer object
- added a check + message for unsupported exports
- list of JsonItems now includes unsupported JsonItems (disabled and marked with 'unsupported')
- refactored the converter type check
- now every converter has to specify its supported type(s)
|
File size:
1000 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 | var maxProp = jObject[nameof(IIntervalRestrictedJsonItem<T>.Maximum)];
|
---|
23 | if (maxProp != null) Maximum = maxProp.ToObject<T>();
|
---|
24 | }
|
---|
25 | }
|
---|
26 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.