Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ConcreteRestrictedValueJsonItem.cs @ 17530

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: 760 bytes
Line 
1using System.Collections.Generic;
2using System.Linq;
3
4namespace HeuristicLab.JsonInterface {
5  public abstract class ConcreteRestrictedValueJsonItem<T> : ValueJsonItem<T>, IConcreteRestrictedJsonItem<T> {
6    public IEnumerable<T> ConcreteRestrictedItems { get; set; }
7
8    protected override ValidationResult Validate() {
9      if (ConcreteRestrictedItems == null) return ValidationResult.Successful();
10      foreach (var x in ConcreteRestrictedItems)
11        if (Value.Equals(x)) return ValidationResult.Successful();
12      return ValidationResult.Faulty(
13        $"[{Path}]: Value {Value} is not one of the allowed values: " +
14        $"'{ string.Join(",", ConcreteRestrictedItems.Select(s => s.ToString()).ToArray()) }'.");
15    }
16  }
17}
Note: See TracBrowser for help on using the repository browser.