Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ServerSignatureViewModel.cs
1using System.Globalization;
2using CommunityToolkit.Mvvm.ComponentModel;
3using CommunityToolkit.Mvvm.Input;
7
9{
14 {
15 private readonly Contract? contract;
16
22 {
23 if (Args is not null)
24 this.contract = Args.Contract;
25 }
26
28 protected override async Task OnInitialize()
29 {
30 await base.OnInitialize();
31
32 this.AssignProperties();
33 }
34
35 #region Properties
36
40 [ObservableProperty]
41 private string? provider;
42
46 [ObservableProperty]
47 private string? timestamp;
48
52 [ObservableProperty]
53 private string? signature;
54
55 #endregion
56
57 private void AssignProperties()
58 {
59 if (this.contract is not null)
60 {
61 this.Provider = this.contract.Provider;
62 this.Timestamp = this.contract.ServerSignature.Timestamp.ToString(CultureInfo.CurrentCulture);
63 this.Signature = Convert.ToBase64String(this.contract.ServerSignature.DigitalSignature);
64 }
65 else
66 {
67 this.Provider = Constants.NotAvailableValue;
68 this.Timestamp = Constants.NotAvailableValue;
69 this.Signature = Constants.NotAvailableValue;
70 }
71 }
72
76 [RelayCommand]
77 private static async Task Copy(object Item)
78 {
79 try
80 {
81 if (Item is string Label)
82 await Clipboard.SetTextAsync(Label);
83 else
84 await Clipboard.SetTextAsync(Item?.ToString() ?? string.Empty);
85
86 await ServiceRef.UiService.DisplayAlert(
87 ServiceRef.Localizer[nameof(AppResources.SuccessTitle)],
88 ServiceRef.Localizer[nameof(AppResources.TagValueCopiedToClipboard)]);
89 }
90 catch (Exception ex)
91 {
92 ServiceRef.LogService.LogException(ex);
93 await ServiceRef.UiService.DisplayException(ex);
94 }
95 }
96 }
97}
A set of never changing property constants and helpful values.
Definition: Constants.cs:7
const string NotAvailableValue
A generic "no value available" string.
Definition: Constants.cs:11
Base class that references services in the app.
Definition: ServiceRef.cs:31
static ILogService LogService
Log service.
Definition: ServiceRef.cs:91
static IUiService UiService
Service serializing and managing UI-related tasks.
Definition: ServiceRef.cs:55
static IStringLocalizer Localizer
Localization service
Definition: ServiceRef.cs:235
A base class for all view models, inheriting from the BindableObject. NOTE: using this class requir...
Holds navigation parameters specific to views displaying a server signature.
The view model to bind to for when displaying server signatures.
ServerSignatureViewModel(ServerSignatureNavigationArgs? Args)
Creates an instance of the ServerSignatureViewModel class.
override async Task OnInitialize()
Method called when view is initialized for the first time. Use this method to implement registration ...
Contains the definition of a contract
Definition: Contract.cs:22