Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TokenNotificationEvent.cs
3using NeuroFeatures;
4using System.Text;
5using System.Xml;
8using Microsoft.Maui.Controls.Shapes;
10
12{
17 {
18 private Token? token;
19
24 : base()
25 {
26 }
27
32 public TokenNotificationEvent(TokenEventArgs e)
33 : base(e)
34 {
35 this.TokenId = e.Token.TokenId;
36 this.FriendlyName = e.Token.FriendlyName;
37 this.TokenCategory = e.Token.Category;
38 this.token = e.Token;
39 this.Category = e.Token.TokenId;
40
41 StringBuilder Xml = new();
42 e.Token.Serialize(Xml);
43 this.TokenXml = Xml.ToString();
44 }
45
50 public TokenNotificationEvent(StateMachineEventArgs e)
51 : base(e)
52 {
53 this.TokenId = e.TokenId;
54 this.token = null;
55 this.TokenXml = null;
56 this.Category = e.TokenId;
57 }
58
62 public string? TokenId { get; set; }
63
67 public string? TokenCategory { get; set; }
68
72 public string? FriendlyName { get; set; }
73
77 public string? TokenXml { get; set; }
78
82 [IgnoreMember]
83 public Token? Token
84 {
85 get
86 {
87 if (this.token is null && !string.IsNullOrEmpty(this.TokenXml))
88 {
89 XmlDocument Doc = new()
90 {
91 PreserveWhitespace = true
92 };
93 Doc.LoadXml(this.TokenXml);
94
95 if (Token.TryParse(Doc.DocumentElement, out Token T))
96 this.token = T;
97 }
98
99 return this.token;
100 }
101
102 set
103 {
104 this.token = value;
105
106 if (value is null)
107 this.TokenXml = null;
108 else
109 {
110 StringBuilder Xml = new();
111 value.Serialize(Xml);
112 this.TokenXml = Xml.ToString();
113 }
114 }
115 }
116
121 public override Task<Geometry> GetCategoryIcon()
122 {
123 return Task.FromResult(Geometries.TokenIconPath);
124 }
125
129 public override Task<string> GetDescription()
130 {
131 if (!string.IsNullOrEmpty(this.FriendlyName))
132 return Task.FromResult(this.FriendlyName);
133 else if (!string.IsNullOrEmpty(this.TokenCategory))
134 return Task.FromResult(this.TokenCategory);
135 else
136 return Task.FromResult(this.TokenId ?? string.Empty);
137 }
138
142 public override async Task Open()
143 {
144 if (string.IsNullOrEmpty(this.TokenId))
145 return;
146
147 this.Token ??= await ServiceRef.XmppService.GetNeuroFeature(this.TokenId);
148
149 if (!ServiceRef.NotificationService.TryGetNotificationEvents(NotificationEventType.Wallet, this.TokenId, out NotificationEvent[]? Events))
150 Events = [];
151
152 TokenDetailsNavigationArgs Args = new(new TokenItem(this.Token, Events));
153
154 await ServiceRef.UiService.GoToAsync(nameof(TokenDetailsPage), Args, BackMethod.Pop);
155 }
156 }
157}
TokenNotificationEvent(TokenEventArgs e)
Abstract base class for token notification events.
override Task< Geometry > GetCategoryIcon()
Gets an icon for the category of event.
TokenNotificationEvent(StateMachineEventArgs e)
Abstract base class for token notification events.
TokenNotificationEvent()
Abstract base class for token notification events.
override Task< string > GetDescription()
Gets a descriptive text for the event.
Base class that references services in the app.
Definition: ServiceRef.cs:31
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:55
static INotificationService NotificationService
Service for managing notifications for the user.
Definition: ServiceRef.cs:211
static IXmppService XmppService
The XMPP service for XMPP communication.
Definition: ServiceRef.cs:67
Static class containing SVG Paths for symbols used in the app.
Definition: Geometries.cs:11
static readonly Geometry TokenIconPath
Token symbol for QR codes
Definition: Geometries.cs:370
A page that allows the user to view information about a token.
Neuro-Feature Token
Definition: Token.cs:43
static bool TryParse(XmlElement Xml, out Token Token)
Serializes the Token, in normalized form.
Definition: Token.cs:523
void Serialize(StringBuilder Xml)
Serializes the Token, in normalized form.
Definition: Token.cs:922
Task GoToAsync(string Route, BackMethod BackMethod=BackMethod.Inherited, string? UniqueId=null)
Navigates the AppShell to the specified route, with page arguments to match.
abstract class NotificationEvent()
Abstract base class of notification events.
NotificationEventType
Button on which event is to be displayed.
BackMethod
Navigation Back Method
Definition: BackMethod.cs:7