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;
5
7{
11 public class Date : ValueNode
12 {
16 public Date()
17 : base()
18 {
19 }
20
24 public System.DateTime Value { get; set; }
25
29 public override string LocalName => nameof(Date);
30
35 public override IStateMachineNode Create()
36 {
37 return new Date();
38 }
39
44 public override Task Parse(XmlElement Xml)
45 {
46 if (!XML.TryParse(Xml.InnerText, out System.DateTime TP))
47 throw new Exception("Invalid DateTime value.");
48
49 if (TP.TimeOfDay != TimeSpan.Zero)
50 throw new Exception("Invalid Date value.");
51
52 this.Value = TP;
53
54 return base.Parse(Xml);
55 }
56
61 public override Task<object> Evaluate(EvaluationArguments Arguments)
62 {
63 return Task.FromResult<object>(this.Value);
64 }
65 }
66}
Helps with common XML-related tasks.
Definition: XML.cs:19
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition: XML.cs:744
Contains information required for evaluating script in a state-machine.
override IStateMachineNode Create()
Creates a new node of the corresponding type.
Definition: Date.cs:35
override Task< object > Evaluate(EvaluationArguments Arguments)
Evaluates the value node.
Definition: Date.cs:61
override Task Parse(XmlElement Xml)
Parses the State-machine node.
Definition: Date.cs:44
Abstract base class for nodes with a value.
Definition: Value.cs:13
Abstract base class for State-Machine nodes containing a value.
Definition: ValueNode.cs:9