Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/RangedJsonItem.cs @ 17591

Last change on this file since 17591 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: 955 bytes
Line 
1using System;
2using System.Collections.Generic;
3
4namespace HeuristicLab.JsonInterface {
5  public abstract class RangedJsonItem<T> : JsonItem, IRangedJsonItem<T>
6    where T : IComparable {
7    public T MinValue { get; set; }
8    public T MaxValue { get; set; }
9    public T Minimum { get; set; }
10    public T Maximum { get; set; }
11
12    protected override ValidationResult Validate() {
13      IList<string> errors = new List<string>();
14      bool successMin = (Minimum.CompareTo(MinValue) <= 0 && Maximum.CompareTo(MinValue) >= 0);
15      bool successMax = (Minimum.CompareTo(MaxValue) <= 0 && Maximum.CompareTo(MaxValue) >= 0);
16      if (!successMin) errors.Add($"[{Path}]: Value {MinValue} is not between {Minimum} and {Maximum}.");
17      if (!successMax) errors.Add($"[{Path}]: Value {MaxValue} is not between {Minimum} and {Maximum}.");
18      return new ValidationResult((successMin && successMax), errors);
19
20    }
21     
22  }
23}
Note: See TracBrowser for help on using the repository browser.