Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PersistedProperty.cs
1using System;
2using System.Threading.Tasks;
4
5namespace LegalLab.Models
6{
11 {
12 private readonly string category;
13
22 public PersistedProperty(string Category, string Name, bool LiveUpdates, T DefaultValue, IModel Model)
23 : base(Name, TimeSpan.FromSeconds(1), LiveUpdates, DefaultValue, Model)
24 {
25 this.category = Category;
26 }
27
31 public string Category => this.category;
32
36 public override async Task Action()
37 {
38 await this.Save();
39 await base.Action();
40 }
41
45 public async Task Load()
46 {
47 this.@value = (T)await RuntimeSettings.GetAsync(this.category + "." + this.Name, this.@value);
48 }
49
53 public async Task Save()
54 {
55 if (this.Changed)
56 {
57 await RuntimeSettings.SetAsync(this.category + "." + this.Name, this.@value);
58
59 this.Changed = false;
60 DelayedActions.Remove(this); // In case saved manually
61 }
62 }
63 }
64}
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
static async Task< bool > SetAsync(string Key, string Value)
Sets a string-valued setting.