Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
VariableModel.cs
1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
5using Waher.Script;
6
8{
14 public partial class VariableModel(string Name, object Value) : BaseViewModel
15 {
16 private readonly string name = Name;
17
21 public string Name => this.name;
22
26 [ObservableProperty]
27 private object value = Value;
28
32 [ObservableProperty]
33 private string asScript = Expression.ToString(Value);
34
39 public void UpdateValue(object Value)
40 {
41 this.Value = Value;
42 this.AsScript = Expression.ToString(Value);
43 }
44
45 #region Commands
46
50 [RelayCommand]
51 private async Task CopyToClipboard()
52 {
53 try
54 {
55 await Clipboard.SetTextAsync(this.AsScript);
56 await ServiceRef.UiService.DisplayAlert(ServiceRef.Localizer[nameof(AppResources.SuccessTitle)],
57 ServiceRef.Localizer[nameof(AppResources.TagValueCopiedToClipboard)]);
58 }
59 catch (Exception ex)
60 {
61 ServiceRef.LogService.LogException(ex);
62 await ServiceRef.UiService.DisplayException(ex);
63 }
64 }
65
66 #endregion
67 }
68}
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
Class managing a script expression.
Definition: Expression.cs:39
static string ToString(double Value)
Converts a value to a string, that can be parsed as part of an expression.
Definition: Expression.cs:4496