Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ScriptParameterNodeWithOptions.cs
2using System.Threading.Tasks;
4
6{
11 {
16 {
17 }
18
22 [Page(2, "Script", 100)]
23 [Header(88, "Restrict to options.")]
24 [ToolTip(89, "If only values defined in options are valid values.")]
25 public bool RestrictToOptions { get; set; }
26
30 public override bool ChildrenOrdered => true;
31
37 public override Task<bool> AcceptsChildAsync(INode Child)
38 {
39 return Task.FromResult(Child is ScriptOptionNode);
40 }
41
46 public async Task<KeyValuePair<string, string>[]> GetOptions()
47 {
48 if (!this.HasChildren)
49 return null;
50
51 IEnumerable<INode> Children = await this.ChildNodes;
52 if (Children is null)
53 return null;
54
55 List<KeyValuePair<string, string>> Result = null;
56
57 foreach (INode Child in Children)
58 {
59 if (Child is ScriptOptionNode Option)
60 {
61 if (Result is null)
62 Result = new List<KeyValuePair<string, string>>();
63
64 Result.Add(new KeyValuePair<string, string>(Option.Label, Option.Value));
65 }
66 }
67
68 return Result?.ToArray();
69 }
70 }
71}
Represents a string-valued option.
Represents a parameter with possible options on a command.
override bool ChildrenOrdered
If the children of the node have an intrinsic order (true), or if the order is not important (false).
bool RestrictToOptions
If only values defined in options are valid values.
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a presumptive child, i.e. can receive as a child (if that child accepts the node ...
ScriptParameterNodeWithOptions()
Represents a parameter with possible options on a command.
async Task< KeyValuePair< string, string >[]> GetOptions()
Gets available options, if any are defined.
Represents a parameter on a command.
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
bool HasChildren
If the source has any child sources.
Definition: INode.cs:76
Task< IEnumerable< INode > > ChildNodes
Child nodes. If no child nodes are available, null is returned.
Definition: INode.cs:140