Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PersistedDataSource.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
4using Waher.Events;
6using Waher.Things;
8
10{
12 {
13 private readonly EventLog eventLog;
14 private readonly INode[] nodes;
15
16 public PersistedDataSource()
17 {
18 this.nodes = new INode[]
19 {
20 this.eventLog = new EventLog()
21 };
22 }
23
24 public string SourceID => "Data";
25 public bool HasChildren => false;
26 public DateTime LastChanged => DateTime.MinValue;
27 public IEnumerable<IDataSource> ChildSources => null;
28 public IEnumerable<INode> RootNodes => this.nodes;
29 public event EventHandlerAsync<SourceEvent> OnEvent;
30
31 public Task<bool> CanViewAsync(RequestOrigin Caller)
32 {
33 return XmppServerModule.IsAdmin(Caller.From);
34 }
35
36 public Task<string> GetNameAsync(Language Language)
37 {
38 return Language.GetStringAsync(typeof(XmppServerModule), 26, "Persisted Data");
39 }
40
41 public Task<INode> GetNodeAsync(IThingReference NodeRef)
42 {
43 switch (NodeRef.Partition)
44 {
45 default:
46 foreach (INode Node in this.nodes)
47 {
48 if (Node.NodeId == NodeRef.NodeId &&
49 Node.SourceId == NodeRef.SourceId &&
50 Node.Partition == NodeRef.Partition)
51 {
52 return Task.FromResult<INode>(Node);
53 }
54 }
55 break;
56 }
57
58
59 return Task.FromResult<INode>(null);
60 }
61 }
62}
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
IEnumerable< INode > RootNodes
Root node references. If no root nodes are available, null is returned.
IEnumerable< IDataSource > ChildSources
Child sources. If no child sources are available, null is returned.
Task< bool > CanViewAsync(RequestOrigin Caller)
If the data source is visible to the caller.
Task< INode > GetNodeAsync(IThingReference NodeRef)
Gets the node, given a reference to it.
Task< string > GetNameAsync(Language Language)
Gets the name of data source.
Service Module hosting the XMPP broker and its components.
Tokens available in request.
Definition: RequestOrigin.cs:9
string From
Address of caller.
Interface for datasources that are published through the concentrator interface.
Definition: IDataSource.cs:14
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
Interface for thing references.
string Partition
Optional partition in which the Node ID is unique.
string SourceId
Optional ID of source containing node.