Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
SingletonMachineId.cs
4
6{
11 {
16 : base()
17 {
18 }
19
23 public override string LocalName => nameof(SingletonMachineId);
24
29 public override IStateMachineNode Create()
30 {
31 return new SingletonMachineId();
32 }
33
38 public override void CheckReferences(StateMachine Machine, Token Token)
39 {
40 if (!this.tag.IsConstant)
41 throw new StateMachineException(Machine, "Singleton Machine IDs must be constant tag references.");
42
43 if (!Token.TryGetTagValue(this.tag.Definition, out object Value))
44 throw new StateMachineException(Machine, "Tag not found: " + this.tag.Definition);
45
46 if (!(Value is string MachineId))
47 throw new StateMachineException(Machine, "Singleton Machine IDs must be strings.");
48
49 int i = MachineId.IndexOf('@');
50 int j = Token.TokenId.IndexOf('@');
51
52 if (j >= 0)
53 {
54 if (i < 0)
55 MachineId += Token.TokenId.Substring(j);
56 else if (MachineId[i..] != Token.TokenId.Substring(j))
57 throw new StateMachineException(this.StateMachine, "Invalid Singleton Machine ID domain.");
58 }
59
60 Machine.StateMachineId = MachineId;
61 }
62 }
63}
CaseInsensitiveString TokenId
Token ID
Definition: Token.cs:145
bool TryGetTagValue(CaseInsensitiveString TagName, out object Value)
Tries to get a TAG value from the token.
Definition: Token.cs:1289
override IStateMachineNode Create()
Creates a new node of the corresponding type.
override void CheckReferences(StateMachine Machine, Token Token)
Checks references in the node.
Abstract base class for nodes with a value.
Definition: Value.cs:14
Class representing a state machine.
Definition: StateMachine.cs:43