1 | using System;
|
---|
2 | using System.Collections;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using System.Linq;
|
---|
5 | using System.Text;
|
---|
6 | using System.Threading.Tasks;
|
---|
7 | using Newtonsoft.Json;
|
---|
8 | using Newtonsoft.Json.Linq;
|
---|
9 |
|
---|
10 | namespace HeuristicLab.JsonInterface {
|
---|
11 | [JsonObject]
|
---|
12 | public interface IJsonItem : IEnumerable<IJsonItem> {
|
---|
13 | /// <summary>
|
---|
14 | /// Only active items are included in templates.
|
---|
15 | /// </summary>
|
---|
16 | bool Active { get; set; }
|
---|
17 |
|
---|
18 | /// <summary>
|
---|
19 | /// The name of the JsonItem. Can be changed freely after fixating the path.
|
---|
20 | /// If the path is not fix, changing the name will have affect of the path.
|
---|
21 | /// </summary>
|
---|
22 | string Name { get; set; }
|
---|
23 |
|
---|
24 | /// <summary>
|
---|
25 | /// A description for the JsonItem.
|
---|
26 | /// </summary>
|
---|
27 | string Description { get; set; }
|
---|
28 |
|
---|
29 | /// <summary>
|
---|
30 | /// The JsonItem path in the related object graph.
|
---|
31 | /// </summary>
|
---|
32 | string Path { get; }
|
---|
33 |
|
---|
34 | /// <summary>
|
---|
35 | /// IEnumerable of all sub JsonItems.
|
---|
36 | /// </summary>
|
---|
37 | [JsonIgnore]
|
---|
38 | IEnumerable<IJsonItem> Children { get; }
|
---|
39 |
|
---|
40 | /// <summary>
|
---|
41 | /// If the JsonItem is a children of an other JsonItem, the parent will be this other JsonItem.
|
---|
42 | /// </summary>
|
---|
43 | [JsonIgnore]
|
---|
44 | IJsonItem Parent { get; set; }
|
---|
45 |
|
---|
46 | /// <summary>
|
---|
47 | /// Returns a validator with integrated caching to validate the JsonItem and all children.
|
---|
48 | /// </summary>
|
---|
49 | /// <returns>JsonItemValidator</returns>
|
---|
50 | IJsonItemValidator GetValidator();
|
---|
51 |
|
---|
52 | /// <summary>
|
---|
53 | /// Add sub JsonItems.
|
---|
54 | /// </summary>
|
---|
55 | /// <param name="childs"></param>
|
---|
56 | void AddChildren(params IJsonItem[] childs);
|
---|
57 | void AddChildren(IEnumerable<IJsonItem> childs);
|
---|
58 |
|
---|
59 | /// <summary>
|
---|
60 | /// Method to generate a Newtonsoft JObject, which describes the JsonItem.
|
---|
61 | /// </summary>
|
---|
62 | /// <returns>Newtonsoft JObject</returns>
|
---|
63 | JObject GenerateJObject();
|
---|
64 |
|
---|
65 | /// <summary>
|
---|
66 | /// To set all necessary JsonItem properties with an given Newtonsoft JObject.
|
---|
67 | /// </summary>
|
---|
68 | /// <param name="jObject">Newtonsoft JObject</param>
|
---|
69 | void SetJObject(JObject jObject);
|
---|
70 | }
|
---|
71 | }
|
---|