Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MailMessage.cs
1using System.Threading.Tasks;
2using System.Xml;
5
7{
11 public class MailMessage : ActionNode
12 {
13 private To to;
14 private Subject subject;
15 private Notes.Content content;
16
20 public MailMessage()
21 : base()
22 {
23 }
24
28 public To To => this.to;
29
33 public Subject Subject => this.subject;
34
38 public Notes.Content Content => this.content;
39
43 public override string LocalName => nameof(MailMessage);
44
49 public override IStateMachineNode Create()
50 {
51 return new MailMessage();
52 }
53
58 public override async Task Parse(XmlElement Xml)
59 {
60 await base.Parse(Xml);
61
63 new System.Type[]
64 {
65 typeof(To),
66 typeof(Subject),
67 typeof(Notes.Content)
68 },
69 new bool[]
70 {
71 true,
72 true,
73 true
74 });
75 }
76
80 protected override void OnChildNodesUpdated()
81 {
82 base.OnChildNodesUpdated();
83
84 this.to = this.GetValueElement<To>();
85 this.subject = this.GetValueElement<Subject>();
86 this.content = this.GetValueElement<Notes.Content>();
87 }
88
93 public override async Task Execute(EvaluationArguments Arguments)
94 {
95 string To = (await this.to.Evaluate(Arguments))?.ToString();
96 string Subject = ((await this.subject.Evaluate(Arguments))?.ToString()) ?? "N/A";
97 object Content = await this.content.Evaluate(Arguments);
98
99 if (!(Content is string Markdown))
100 {
101 if (Content is null)
102 Markdown = "N/A";
104 Markdown = MarkdownContent.Markdown;
105 else
106 Markdown = Content.ToString();
107 }
108
109 await XmppServerModule.SendMailMessage(To, Subject, Markdown);
110 }
111 }
112}
Class that can be used to encapsulate Markdown to be returned from a Web Service, bypassing any encod...
Abstract base class for State-Machine action nodes.
Definition: ActionNode.cs:9
override async Task Parse(XmlElement Xml)
Parses the State-machine node.
Definition: MailMessage.cs:58
override void OnChildNodesUpdated()
Method called whenever ChildNodes is updated.
Definition: MailMessage.cs:80
override IStateMachineNode Create()
Creates a new node of the corresponding type.
Definition: MailMessage.cs:49
override async Task Execute(EvaluationArguments Arguments)
Evaluates the action node
Definition: MailMessage.cs:93
Defines to whom a payment (or message) is sent.
Definition: To.cs:9
Contains information required for evaluating script in a state-machine.
void ConvertValueAttributesToElements(XmlElement Xml, Type[] ValueTypes, bool[] Required)
Converts value attributes to parsed elements. The XML definition has to be parsed before,...
Task< object > Evaluate(EvaluationArguments Arguments)
Evaluates the value node.
Definition: Value.cs:146
Service Module hosting the XMPP broker and its components.
static Task< bool > SendMailMessage(string To, string Subject, string Markdown)
Sends a mail message