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 | /// This method fixates the path.
|
---|
61 | /// After calling, the path cannot be changed by changing the name or parent.
|
---|
62 | /// </summary>
|
---|
63 | void FixatePath();
|
---|
64 |
|
---|
65 | /// <summary>
|
---|
66 | /// This method looses the path again after a call of FixatePath.
|
---|
67 | /// After calling, the path is calculated by the position in item tree again.
|
---|
68 | /// </summary>
|
---|
69 | void LoosenPath();
|
---|
70 |
|
---|
71 | /// <summary>
|
---|
72 | /// Method to generate a Newtonsoft JObject, which describes the JsonItem.
|
---|
73 | /// </summary>
|
---|
74 | /// <returns>Newtonsoft JObject</returns>
|
---|
75 | JObject GenerateJObject();
|
---|
76 |
|
---|
77 | /// <summary>
|
---|
78 | /// To set all necessary JsonItem properties with an given Newtonsoft JObject.
|
---|
79 | /// </summary>
|
---|
80 | /// <param name="jObject">Newtonsoft JObject</param>
|
---|
81 | void SetJObject(JObject jObject);
|
---|
82 | }
|
---|
83 | }
|
---|