Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/JsonItems/ConcreteRestrictedValueJsonItem.cs @ 17829

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