Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.JsonInterface/Models/ValueLookupJsonItem.cs @ 17483

Last change on this file since 17483 was 17483, checked in by dpiringe, 4 years ago

#3026:

  • added readme JsonInterfaceReadMe.txt
  • removed dead code
  • fixed a bug in JsonItemConverter -> now the type comparison should work as intended
File size: 1.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using Newtonsoft.Json;
7using Newtonsoft.Json.Linq;
8
9namespace HeuristicLab.JsonInterface {
10  public class ValueLookupJsonItem : LookupJsonItem, IValueLookupJsonItem {
11    public IJsonItem ActualValue { get; set; }
12
13    protected override ValidationResult Validate() {
14      if (ActualValue == null) return ValidationResult.Successful();
15      return ActualValue.GetValidator().Validate();
16    }
17
18    public override JObject GenerateJObject() {
19      var obj = base.GenerateJObject();
20      if(ActualValue != null) {
21        obj.Add(nameof(IValueLookupJsonItem.ActualValue), ActualValue.Path);
22      }
23      return obj;
24    }
25
26    public override IEnumerator<IJsonItem> GetEnumerator() {
27      using (var it = base.GetEnumerator()) {
28        while(it.MoveNext()) {
29          yield return it.Current;
30        }
31      }
32      if(ActualValue != null) {
33        using (var it = ActualValue.GetEnumerator()) {
34          while (it.MoveNext()) {
35            yield return it.Current;
36          }
37        }
38      }
39    }
40  }
41}
Note: See TracBrowser for help on using the repository browser.