Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
OnPaymentSent.cs
1using System.Threading.Tasks;
2using System.Xml;
9
11{
15 public class OnPaymentSent : OnPayment
16 {
17 private ScriptableStringAttribute toVariable;
18
23 : base()
24 {
25 }
26
30 [DefaultValueNull]
32 {
33 get => this.toVariable?.Definition;
34 set => this.toVariable = new ScriptableStringAttribute(value, this);
35 }
36
40 public override string LocalName => nameof(OnPaymentSent);
41
46 public override IStateMachineNode Create()
47 {
48 return new OnPaymentSent();
49 }
50
55 public override Task Parse(XmlElement Xml)
56 {
57 this.toVariable = new ScriptableStringAttribute(XML.Attribute(Xml, "toVariable"), this);
58
59 return base.Parse(Xml);
60 }
61
65 public override string Label => nameof(OnPaymentSent);
66
74 public override async Task<bool> Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
75 {
76 string ToVariable = await this.toVariable.Evaluate(Arguments.Variables);
77 string AmountVariable = await this.amountVariable.Evaluate(Arguments.Variables);
78 string AmountExtraVariable = await this.amountExtraVariable.Evaluate(Arguments.Variables);
79 string AmountTotalVariable = await this.amountTotalVariable.Evaluate(Arguments.Variables);
80 string CurrencyVariable = await this.currencyVariable.Evaluate(Arguments.Variables);
81 string ReferenceVariable = await this.referenceVariable.Evaluate(Arguments.Variables);
82 string ConditionVariable = await this.conditionVariable.Evaluate(Arguments.Variables);
83
85 EventIndex, this, Arguments.Token.OwnerJid, ToVariable, AmountVariable, AmountExtraVariable,
86 AmountTotalVariable, CurrencyVariable, ReferenceVariable, ConditionVariable);
87
88 await Database.Insert(Handler);
89 await Handler.AddToCache();
90
91 return false;
92 }
93 }
94}
Helps with common XML-related tasks.
Definition: XML.cs:19
static string Attribute(XmlElement E, string Name)
Gets the value of an XML attribute.
Definition: XML.cs:914
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:19
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Definition: Database.cs:95
async Task AddToCache()
Removes the event handler from the cache.
async Task< T > Evaluate(Variables Variables)
Evaluates the attribute
Contains information required for evaluating script in a state-machine.
Abstract base class for payment events.
Definition: OnPayment.cs:13
ScriptableStringAttribute amountTotalVariable
Amount total variable
Definition: OnPayment.cs:27
ScriptableStringAttribute amountExtraVariable
Amount extra variable
Definition: OnPayment.cs:22
ScriptableStringAttribute amountVariable
Amount variable
Definition: OnPayment.cs:17
ScriptableStringAttribute currencyVariable
Currency variable
Definition: OnPayment.cs:32
ScriptableStringAttribute conditionVariable
Condition variable
Definition: OnPayment.cs:42
ScriptableStringAttribute referenceVariable
Reference variable
Definition: OnPayment.cs:37
override IStateMachineNode Create()
Creates a new node of the corresponding type.
OnPaymentSent()
Event raised when a payment has been sent.
override Task Parse(XmlElement Xml)
Parses the State-machine node.
override async Task< bool > Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
Registers the event
Action executed when entering a state.
Definition: OnEvent.cs:17