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 | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 | using Newtonsoft.Json;
|
---|
7 | using Newtonsoft.Json.Linq;
|
---|
8 |
|
---|
9 | namespace 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.