Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Date.cs
1using System;
2using System.Threading.Tasks;
3using System.Xml;
6
8{
12 public class Date : ValueNode
13 {
17 public Date()
18 : base()
19 {
20 }
21
25 public System.DateTime Value { get; set; }
26
30 public override string LocalName => nameof(Date);
31
36 public override IStateMachineNode Create()
37 {
38 return new Date();
39 }
40
45 public override Task Parse(XmlElement Xml)
46 {
47 if (!XML.TryParse(Xml.InnerText, out System.DateTime TP))
48 throw new StateMachineException(this.StateMachine, "Invalid DateTime value.");
49
50 if (TP.TimeOfDay != TimeSpan.Zero)
51 throw new StateMachineException(this.StateMachine, "Invalid Date value.");
52
53 this.Value = TP;
54
55 return base.Parse(Xml);
56 }
57
62 public override Task<object> Evaluate(EvaluationArguments Arguments)
63 {
64 return Task.FromResult<object>(this.Value);
65 }
66 }
67}
Helps with common XML-related tasks.
Definition: XML.cs:21
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition: XML.cs:892
Contains information required for evaluating script in a state-machine.
override IStateMachineNode Create()
Creates a new node of the corresponding type.
Definition: Date.cs:36
override Task< object > Evaluate(EvaluationArguments Arguments)
Evaluates the value node.
Definition: Date.cs:62
override Task Parse(XmlElement Xml)
Parses the State-machine node.
Definition: Date.cs:45
Abstract base class for nodes with a value.
Definition: Value.cs:14
Abstract base class for State-Machine nodes containing a value.
Definition: ValueNode.cs:9
Class representing a state machine.
Definition: StateMachine.cs:43