Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Icons.cs
1using System;
4
6{
10 public class Icons
11 {
15 public Icons()
16 {
17 }
18
23 public Icons(params Icon[] Icons)
24 {
25 this.IconArray = Icons;
26 }
27
39 public Icon[]? IconArray { get; internal set; }
40
44 public bool Empty => (this.IconArray?.Length ?? 0) == 0;
45
52 public static bool TryParse(Dictionary<string, object> Generic,
53 out Icons Typed)
54 {
55 Icons Result = new Icons();
56
57 if (Generic.TryGetValue("icons", out object? Obj) && Obj is Array Icons)
58 {
59 ChunkedList<Icon> IconList = new ChunkedList<Icon>();
60
61 foreach (object Item in Icons)
62 {
63 if (Item is Dictionary<string, object> IconObj &&
64 Icon.TryParse(IconObj, out Icon TypedIcon))
65 {
66 IconList.Add(TypedIcon);
67 }
68 }
69
70 Result.IconArray = IconList.ToArray();
71 }
72
73 Typed = Result;
74 return true;
75 }
76
81 public Dictionary<string, object>[] ToJson()
82 {
83 if (this.IconArray is null)
84 return Array.Empty<Dictionary<string, object>>();
85
86 Dictionary<string, object>[] Result = new Dictionary<string, object>[this.IconArray.Length];
87 for (int i = 0; i < this.IconArray.Length; i++)
88 Result[i] = this.IconArray[i].ToJson();
89
90 return Result;
91 }
92 }
93}
An optionally-sized icon that can be displayed in a user interface.
Definition: Icon.cs:10
static bool TryParse(Dictionary< string, object > Generic, out Icon Typed)
Tries to parse a generic structure into a typed structure.
Definition: Icon.cs:87
Base interface to add icons property.
Definition: Icons.cs:11
Icons()
Base interface to add icons property.
Definition: Icons.cs:15
static bool TryParse(Dictionary< string, object > Generic, out Icons Typed)
Tries to parse a generic structure into a typed structure.
Definition: Icons.cs:52
bool Empty
If there are icons defined.
Definition: Icons.cs:44
Icon?[] IconArray
Optional set of sized icons that the client can display in a user interface.
Definition: Icons.cs:39
Icons(params Icon[] Icons)
Base interface to add icons property.
Definition: Icons.cs:23
Dictionary< string, object >[] ToJson()
Converts object to a generic representation.
Definition: Icons.cs:81
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54