Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
OnTransferred.cs
1using System.Threading.Tasks;
2using System.Xml;
9
11{
16 {
17 private ScriptableStringAttribute sellerVariable;
18 private ScriptableStringAttribute buyerVariable;
19 private ScriptableStringAttribute contractVariable;
20 private ScriptableStringAttribute valueVariable;
21 private ScriptableStringAttribute amountVariable;
22 private ScriptableStringAttribute currencyVariable;
23
28 : base()
29 {
30 }
31
35 [DefaultValueNull]
37 {
38 get => this.sellerVariable?.Definition;
39 set => this.sellerVariable = new ScriptableStringAttribute(value, this);
40 }
41
45 [DefaultValueNull]
47 {
48 get => this.buyerVariable?.Definition;
49 set => this.buyerVariable = new ScriptableStringAttribute(value, this);
50 }
51
55 [DefaultValueNull]
57 {
58 get => this.contractVariable?.Definition;
59 set => this.contractVariable = new ScriptableStringAttribute(value, this);
60 }
61
65 [DefaultValueNull]
67 {
68 get => this.valueVariable?.Definition;
69 set => this.valueVariable = new ScriptableStringAttribute(value, this);
70 }
71
75 [DefaultValueNull]
77 {
78 get => this.amountVariable?.Definition;
79 set => this.amountVariable = new ScriptableStringAttribute(value, this);
80 }
81
85 [DefaultValueNull]
87 {
88 get => this.currencyVariable?.Definition;
89 set => this.currencyVariable = new ScriptableStringAttribute(value, this);
90 }
91
95 public override string LocalName => nameof(OnTransferred);
96
101 public override IStateMachineNode Create()
102 {
103 return new OnTransferred();
104 }
105
110 public override Task Parse(XmlElement Xml)
111 {
112 this.sellerVariable = new ScriptableStringAttribute(XML.Attribute(Xml, "sellerVariable"), this);
113 this.buyerVariable = new ScriptableStringAttribute(XML.Attribute(Xml, "buyerVariable"), this);
114 this.contractVariable = new ScriptableStringAttribute(XML.Attribute(Xml, "contractVariable"), this);
115 this.valueVariable = new ScriptableStringAttribute(XML.Attribute(Xml, "valueVariable"), this);
116 this.amountVariable = new ScriptableStringAttribute(XML.Attribute(Xml, "amountVariable"), this);
117 this.currencyVariable = new ScriptableStringAttribute(XML.Attribute(Xml, "currencyVariable"), this);
118
119 return base.Parse(Xml);
120 }
121
122 public override async Task<bool> Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
123 {
124 string SellerVariable = await this.sellerVariable.Evaluate(Arguments.Variables);
125 string BuyerVariable = await this.buyerVariable.Evaluate(Arguments.Variables);
126 string ContractVariable = await this.contractVariable.Evaluate(Arguments.Variables);
127 string ValueVariable = await this.valueVariable.Evaluate(Arguments.Variables);
128 string AmountVariable = await this.amountVariable.Evaluate(Arguments.Variables);
129 string CurrencyVariable = await this.currencyVariable.Evaluate(Arguments.Variables);
130
132 EventIndex, this, SellerVariable, BuyerVariable, ContractVariable, ValueVariable,
133 AmountVariable, CurrencyVariable);
134
135 await Database.Insert(Handler);
136 await Handler.AddToCache();
137
138 return false;
139 }
140
144 public override string Label => nameof(OnTransferred);
145
146 // TODO: When transfered: Reregister payment event handlers
147 }
148}
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.
Event raised when the associated token is transferred to a new owner.
override async Task< bool > Register(int EventIndex, EvaluationArguments Arguments, OnEvent Event)
Registers the event
override IStateMachineNode Create()
Creates a new node of the corresponding type.
string CurrencyVariableDefinition
Currency Variable definition.
OnTransferred()
Event raised when the associated token is transferred to a new owner.
override Task Parse(XmlElement Xml)
Parses the State-machine node.
string ContractVariableDefinition
Contract Variable definition.
Action executed when entering a state.
Definition: OnEvent.cs:17