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);
137 return this.children.ToArray();
142 internal IEnumerable<ConfigurationNode> Siblings => this.parent?.children;
192 return Task.FromResult<IEnumerable<Parameter>>(Array.Empty<
Parameter>());
209 Task.FromResult(
false);
211 lock (this.parent.children)
213 int i = this.parent.children.IndexOf(
this);
215 return Task.FromResult(
false);
217 this.parent.children.RemoveAt(i);
218 this.parent.children.Insert(i - 1,
this);
220 return Task.FromResult(
true);
232 Task.FromResult(
false);
234 lock (this.parent.children)
236 int i = this.parent.children.IndexOf(
this);
237 if (i < 0 || i >= this.parent.children.Count - 1)
238 return Task.FromResult(
false);
240 this.parent.children.RemoveAt(i);
241 this.parent.children.Insert(i + 1,
this);
243 return Task.FromResult(
true);
268 throw new InvalidOperationException(
"Incompatible type.");
272 return this.source?.NodeAdded(Child,
false) ?? Task.CompletedTask;
279 this.children.Add(Child);
282 Child.source = this.source;
289 public virtual Task
UpdateAsync() => this.source?.NodeUpdated(
this,
false) ?? Task.CompletedTask;
299 return Task.FromResult(
false);
310 public virtual Task
DestroyAsync() => this.source?.NodeDeleted(
this,
false) ?? Task.CompletedTask;
315 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 SourceID
Source ID for the reports data source.
Base class for all node parameters.
Tokens available in request.
bool HasPrivilege(string Privilege)
If the origin has a given privilege.
Interface for nodes that are published through the concentrator interface.
NodeState
State of a node.