2using System.Collections.Generic;
3using System.Threading.Tasks;
15 private readonly List<ConfigurationNode> children =
new List<ConfigurationNode>();
49 public abstract string NodeId {
get; }
86 return this.children.Count > 0;
129 public virtual Task<IEnumerable<INode>>
ChildNodes => Task.FromResult<IEnumerable<INode>>(this.children);
131 internal INode[] Children
137 return this.children.ToArray();
178 return Task.FromResult<IEnumerable<Parameter>>(
new Parameter[0]);
195 Task.FromResult(
false);
197 lock (this.parent.children)
199 int i = this.parent.children.IndexOf(
this);
201 return Task.FromResult(
false);
203 this.parent.children.RemoveAt(i);
204 this.parent.children.Insert(i - 1,
this);
206 return Task.FromResult(
true);
218 Task.FromResult(
false);
220 lock (this.parent.children)
222 int i = this.parent.children.IndexOf(
this);
223 if (i < 0 || i >= this.parent.children.Count - 1)
224 return Task.FromResult(
false);
226 this.parent.children.RemoveAt(i);
227 this.parent.children.Insert(i + 1,
this);
229 return Task.FromResult(
true);
254 throw new InvalidOperationException(
"Incompatible type.");
258 return this.source?.NodeAdded(Child,
false) ?? Task.CompletedTask;
265 this.children.Add(Child);
268 Child.source = this.source;
275 public virtual Task
UpdateAsync() => this.source?.NodeUpdated(
this,
false) ?? Task.CompletedTask;
285 return Task.FromResult(
false);
296 public virtual Task
DestroyAsync() => this.source?.NodeDeleted(
this,
false) ?? Task.CompletedTask;
301 public virtual Task<IEnumerable<ICommand>>
Commands => Task.FromResult<IEnumerable<ICommand>>(
null);
Contains information about a language.
Abstract base class for gateway configuration nodes.
virtual Task UpdateAsync()
Updates the node (in persisted storage).
virtual bool ChildrenOrdered
If the children of the node have an intrinsic order (true), or if the order is not important (false).
virtual Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
virtual Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a presumptive parent, i.e. can be added to that parent (if that parent accepts th...
virtual Task< IEnumerable< ICommand > > Commands
Available command objects. If no commands are available, null is returned.
virtual Task< bool > CanEditAsync(RequestOrigin Caller)
If the node can be edited by the caller.
virtual Task< bool > MoveUpAsync(RequestOrigin Caller)
Tries to move the node up.
ConfigurationNode()
Abstract base class for gateway configuration nodes.
abstract Task< string > GetTypeNameAsync(Language Language)
Gets the type name of the node.
virtual Task< IEnumerable< INode > > ChildNodes
Child nodes. If no child nodes are available, null is returned.
virtual Task< bool > RemoveAsync(INode Child)
Removes a child from the node.
virtual bool HasCommands
If the node has registered commands or not.
virtual Task< bool > MoveDownAsync(RequestOrigin Caller)
Tries to move the node down.
string LogId
If provided, an ID for the node, as it would appear or be used in system logs. Can be null,...
virtual Task< bool > CanDestroyAsync(RequestOrigin Caller)
If the node can be destroyed to by the caller.
virtual Task AddAsync(INode Child)
Adds a new child to the node.
NodeState State
Current overall state of the node.
virtual Task< IEnumerable< Message > > GetMessagesAsync(RequestOrigin Caller)
Gets messages logged on the node.
Task< bool > CanViewAsync(RequestOrigin Caller)
If the node is visible to the caller.
string Partition
Optional partition in which the Node ID is unique.
virtual INode Parent
Parent Node, or null if a root node.
virtual 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 ...
ConfigurationNode(GatewayConfigSource Source, ConfigurationNode Parent)
Abstract base class for gateway configuration nodes.
GatewayConfigSource Source
Source hosting the node.
DateTime LastChanged
When the node was last updated.
virtual Task< bool > CanAddAsync(RequestOrigin Caller)
If the node can be added to by the caller.
virtual bool HasChildren
If the source has any child sources.
abstract string NodeId
ID of node.
virtual Task DestroyAsync()
Destroys the node. If it is a child to a parent node, it is removed from the parent first.
virtual string LocalId
If provided, an ID for the node, but unique locally between siblings. Can be null,...
bool IsReadable
If the node can be read.
bool IsControllable
If the node can be controlled.
string SourceId
Optional ID of source containing node.
Data source mirroring the Gateway.config file.
const string GatewayConfigSourceID
Data source mirroring the Gateway.config file.
Service Module hosting the XMPP broker and its components.
Base class for all node parameters.
Tokens available in request.
Interface for nodes that are published through the concentrator interface.
NodeState
State of a node.