Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17829 was 17519, checked in by dpiringe, 4 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: 1.0 KB
Line 
1using System.Collections.Generic;
2using Newtonsoft.Json.Linq;
3
4namespace HeuristicLab.JsonInterface {
5  public class ValueLookupJsonItem : LookupJsonItem, IValueLookupJsonItem {
6    public IJsonItem ActualValue { get; set; }
7
8    protected override ValidationResult Validate() {
9      if (ActualValue == null) return ValidationResult.Successful();
10      return ActualValue.GetValidator().Validate();
11    }
12
13    public override JObject GenerateJObject() {
14      var obj = base.GenerateJObject();
15      if(ActualValue != null) {
16        obj.Add(nameof(IValueLookupJsonItem.ActualValue), ActualValue.Path);
17      }
18      return obj;
19    }
20
21    public override IEnumerator<IJsonItem> GetEnumerator() {
22      using (var it = base.GetEnumerator()) {
23        while(it.MoveNext()) {
24          yield return it.Current;
25        }
26      }
27      if(ActualValue != null) {
28        using (var it = ActualValue.GetEnumerator()) {
29          while (it.MoveNext()) {
30            yield return it.Current;
31          }
32        }
33      }
34    }
35  }
36}
Note: See TracBrowser for help on using the repository browser.