Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
UserSettings.cs
1using System;
3using System.Reflection;
4using System.Threading.Tasks;
10
12{
17 public static class UserSettings
18 {
19 #region String-valued settings
20
28 public static string Get(string User, string Key, string DefaultValue)
29 {
30 return GetAsync(User, Key, DefaultValue).Result;
31 }
32
40 public static async Task<string> GetAsync(string User, string Key, string DefaultValue)
41 {
42 StringUserSetting Setting = await GetAsync<StringUserSetting>(User, Key);
43 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
44 }
45
46 private static async Task<T> GetAsync<T>(string User, string Key)
47 where T : class
48 {
49 using (Semaphore Semaphore = await Semaphores.BeginRead("usersetting:" + User + " " + Key))
50 {
51 T Setting = await Database.FindFirstDeleteRest<T>(new FilterAnd(
52 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
53
54 return Setting;
55 }
56 }
57
65 public static bool Set(string User, string Key, string Value)
66 {
67 return SetAsync(User, Key, Value).Result;
68 }
69
77 public static async Task<bool> SetAsync(string User, string Key, string Value)
78 {
79 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
80 {
81 StringUserSetting Setting = await Database.FindFirstDeleteRest<StringUserSetting>(new FilterAnd(
82 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
83 return await SetAsyncLocked(User, Key, Value, Setting);
84 }
85 }
86
87 private static async Task<bool> SetAsyncLocked(string User, string Key, string Value, StringUserSetting Setting)
88 {
89 if (Setting is null)
90 {
91 Setting = new StringUserSetting(User, Key, Value);
92 await Database.Insert(Setting);
93
94 return true;
95 }
96 else
97 {
98 if (Setting.Value != Value)
99 {
100 Setting.Value = Value;
101 await Database.Update(Setting);
102
103 return true;
104 }
105 else
106 return false;
107 }
108 }
109
110 #endregion
111
112 #region Int64-valued settings
113
121 public static long Get(string User, string Key, long DefaultValue)
122 {
123 return GetAsync(User, Key, DefaultValue).Result;
124 }
125
133 public static async Task<long> GetAsync(string User, string Key, long DefaultValue)
134 {
135 Int64UserSetting Setting = await GetAsync<Int64UserSetting>(User, Key);
136 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
137 }
138
146 public static bool Set(string User, string Key, long Value)
147 {
148 return SetAsync(User, Key, Value).Result;
149 }
150
158 public static async Task<bool> SetAsync(string User, string Key, long Value)
159 {
160 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
161 {
162 Int64UserSetting Setting = await Database.FindFirstDeleteRest<Int64UserSetting>(new FilterAnd(
163 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
164 return await SetAsyncLocked(User, Key, Value, Setting);
165 }
166 }
167
168 private static async Task<bool> SetAsyncLocked(string User, string Key, long Value, Int64UserSetting Setting)
169 {
170 if (Setting is null)
171 {
172 Setting = new Int64UserSetting(User, Key, Value);
173 await Database.Insert(Setting);
174
175 return true;
176 }
177 else
178 {
179 if (Setting.Value != Value)
180 {
181 Setting.Value = Value;
182 await Database.Update(Setting);
183
184 return true;
185 }
186 else
187 return false;
188 }
189 }
190
191 #endregion
192
193 #region Boolean-valued settings
194
202 public static bool Get(string User, string Key, bool DefaultValue)
203 {
204 return GetAsync(User, Key, DefaultValue).Result;
205 }
206
214 public static async Task<bool> GetAsync(string User, string Key, bool DefaultValue)
215 {
216 BooleanUserSetting Setting = await GetAsync<BooleanUserSetting>(User, Key);
217 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
218 }
219
227 public static bool Set(string User, string Key, bool Value)
228 {
229 return SetAsync(User, Key, Value).Result;
230 }
231
239 public static async Task<bool> SetAsync(string User, string Key, bool Value)
240 {
241 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
242 {
243 BooleanUserSetting Setting = await Database.FindFirstDeleteRest<BooleanUserSetting>(new FilterAnd(
244 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
245 return await SetAsyncLocked(User, Key, Value, Setting);
246 }
247 }
248
249 private static async Task<bool> SetAsyncLocked(string User, string Key, bool Value, BooleanUserSetting Setting)
250 {
251 if (Setting is null)
252 {
253 Setting = new BooleanUserSetting(User, Key, Value);
254 await Database.Insert(Setting);
255
256 return true;
257 }
258 else
259 {
260 if (Setting.Value != Value)
261 {
262 Setting.Value = Value;
263 await Database.Update(Setting);
264
265 return true;
266 }
267 else
268 return false;
269 }
270 }
271
272 #endregion
273
274 #region DateTime-valued settings
275
283 public static DateTime Get(string User, string Key, DateTime DefaultValue)
284 {
285 return GetAsync(User, Key, DefaultValue).Result;
286 }
287
295 public static async Task<DateTime> GetAsync(string User, string Key, DateTime DefaultValue)
296 {
297 DateTimeUserSetting Setting = await GetAsync<DateTimeUserSetting>(User, Key);
298 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
299 }
300
308 public static bool Set(string User, string Key, DateTime Value)
309 {
310 return SetAsync(User, Key, Value).Result;
311 }
312
320 public static async Task<bool> SetAsync(string User, string Key, DateTime Value)
321 {
322 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
323 {
324 DateTimeUserSetting Setting = await Database.FindFirstDeleteRest<DateTimeUserSetting>(new FilterAnd(
325 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
326 return await SetAsyncLocked(User, Key, Value, Setting);
327 }
328 }
329
330 private static async Task<bool> SetAsyncLocked(string User, string Key, DateTime Value, DateTimeUserSetting Setting)
331 {
332 if (Setting is null)
333 {
334 Setting = new DateTimeUserSetting(User, Key, Value);
335 await Database.Insert(Setting);
336
337 return true;
338 }
339 else
340 {
341 if (Setting.Value != Value)
342 {
343 Setting.Value = Value;
344 await Database.Update(Setting);
345
346 return true;
347 }
348 else
349 return false;
350 }
351 }
352
353 #endregion
354
355 #region TimeSpan-valued settings
356
364 public static TimeSpan Get(string User, string Key, TimeSpan DefaultValue)
365 {
366 return GetAsync(User, Key, DefaultValue).Result;
367 }
368
376 public static async Task<TimeSpan> GetAsync(string User, string Key, TimeSpan DefaultValue)
377 {
378 TimeSpanUserSetting Setting = await GetAsync<TimeSpanUserSetting>(User, Key);
379 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
380 }
381
389 public static bool Set(string User, string Key, TimeSpan Value)
390 {
391 return SetAsync(User, Key, Value).Result;
392 }
393
401 public static async Task<bool> SetAsync(string User, string Key, TimeSpan Value)
402 {
403 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
404 {
405 TimeSpanUserSetting Setting = await Database.FindFirstDeleteRest<TimeSpanUserSetting>(new FilterAnd(
406 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
407 return await SetAsyncLocked(User, Key, Value, Setting);
408 }
409 }
410
411 private static async Task<bool> SetAsyncLocked(string User, string Key, TimeSpan Value, TimeSpanUserSetting Setting)
412 {
413 if (Setting is null)
414 {
415 Setting = new TimeSpanUserSetting(User, Key, Value);
416 await Database.Insert(Setting);
417
418 return true;
419 }
420 else
421 {
422 if (Setting.Value != Value)
423 {
424 Setting.Value = Value;
425 await Database.Update(Setting);
426
427 return true;
428 }
429 else
430 return false;
431 }
432 }
433
434 #endregion
435
436 #region Double-valued settings
437
445 public static double Get(string User, string Key, double DefaultValue)
446 {
447 return GetAsync(User, Key, DefaultValue).Result;
448 }
449
457 public static async Task<double> GetAsync(string User, string Key, double DefaultValue)
458 {
459 DoubleUserSetting Setting = await GetAsync<DoubleUserSetting>(User, Key);
460 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
461 }
462
470 public static bool Set(string User, string Key, double Value)
471 {
472 return SetAsync(User, Key, Value).Result;
473 }
474
482 public static async Task<bool> SetAsync(string User, string Key, double Value)
483 {
484 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
485 {
486 DoubleUserSetting Setting = await Database.FindFirstDeleteRest<DoubleUserSetting>(new FilterAnd(
487 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
488 return await SetAsyncLocked(User, Key, Value, Setting);
489 }
490 }
491
492 private static async Task<bool> SetAsyncLocked(string User, string Key, double Value, DoubleUserSetting Setting)
493 {
494 if (Setting is null)
495 {
496 Setting = new DoubleUserSetting(User, Key, Value);
497 await Database.Insert(Setting);
498
499 return true;
500 }
501 else
502 {
503 if (Setting.Value != Value)
504 {
505 Setting.Value = Value;
506 await Database.Update(Setting);
507
508 return true;
509 }
510 else
511 return false;
512 }
513 }
514
515 #endregion
516
517 #region Enum-valued settings
518
526 public static Enum Get(string User, string Key, Enum DefaultValue)
527 {
528 return GetAsync(User, Key, DefaultValue).Result;
529 }
530
538 public static async Task<Enum> GetAsync(string User, string Key, Enum DefaultValue)
539 {
540 EnumUserSetting Setting = await GetAsync<EnumUserSetting>(User, Key);
541 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
542 }
543
551 public static bool Set(string User, string Key, Enum Value)
552 {
553 return SetAsync(User, Key, Value).Result;
554 }
555
563 public static async Task<bool> SetAsync(string User, string Key, Enum Value)
564 {
565 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
566 {
567 EnumUserSetting Setting = await Database.FindFirstDeleteRest<EnumUserSetting>(new FilterAnd(
568 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
569 return await SetAsyncLocked(User, Key, Value, Setting);
570 }
571 }
572
573 private static async Task<bool> SetAsyncLocked(string User, string Key, Enum Value, EnumUserSetting Setting)
574 {
575 if (Setting is null)
576 {
577 Setting = new EnumUserSetting(User, Key, Value);
578 await Database.Insert(Setting);
579
580 return true;
581 }
582 else
583 {
584 if (Setting.Value != Value)
585 {
586 Setting.Value = Value;
587 await Database.Update(Setting);
588
589 return true;
590 }
591 else
592 return false;
593 }
594 }
595
596 #endregion
597
598 #region Object-valued settings
599
607 public static object Get(string User, string Key, object DefaultValue)
608 {
609 return GetAsync(User, Key, DefaultValue).Result;
610 }
611
619 public static async Task<object> GetAsync(string User, string Key, object DefaultValue)
620 {
621 UserSetting Setting = await GetAsync<UserSetting>(User, Key);
622 return Setting?.GetValueObject() ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
623 }
624
632 public static bool Set(string User, string Key, object Value)
633 {
634 return SetAsync(User, Key, Value).Result;
635 }
636
644 public static async Task<bool> SetAsync(string User, string Key, object Value)
645 {
646 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
647 {
648 UserSetting Setting = await Database.FindFirstDeleteRest<UserSetting>(new FilterAnd(
649 new FilterFieldEqualTo("User", User), new FilterFieldEqualTo("Key", Key)));
650
651 if (Value is null)
652 {
653 if (!(Setting is ObjectUserSetting))
654 {
655 if (!(Setting is null))
656 await Database.Delete(Setting);
657
658 Setting = null;
659 }
660 }
661 else
662 {
663 if (Value is string s)
664 {
665 if (!(Setting is StringUserSetting StringSetting))
666 {
667 if (!(Setting is null))
668 await Database.Delete(Setting);
669
670 StringSetting = null;
671 }
672
673 return await SetAsyncLocked(User, Key, s, StringSetting);
674 }
675 else if (Value is long l)
676 {
677 if (!(Setting is Int64UserSetting Int64Setting))
678 {
679 if (!(Setting is null))
680 await Database.Delete(Setting);
681
682 Int64Setting = null;
683 }
684
685 return await SetAsyncLocked(User, Key, l, Int64Setting);
686 }
687 else if (Value is double d)
688 {
689 if (!(Setting is DoubleUserSetting DoubleSetting))
690 {
691 if (!(Setting is null))
692 await Database.Delete(Setting);
693
694 DoubleSetting = null;
695 }
696
697 return await SetAsyncLocked(User, Key, d, DoubleSetting);
698 }
699 else if (Value is bool b)
700 {
701 if (!(Setting is BooleanUserSetting BooleanSetting))
702 {
703 if (!(Setting is null))
704 await Database.Delete(Setting);
705
706 BooleanSetting = null;
707 }
708
709 return await SetAsyncLocked(User, Key, b, BooleanSetting);
710 }
711 else if (Value is DateTime TP)
712 {
713 if (!(Setting is DateTimeUserSetting DateTimeSetting))
714 {
715 if (!(Setting is null))
716 await Database.Delete(Setting);
717
718 DateTimeSetting = null;
719 }
720
721 return await SetAsyncLocked(User, Key, TP, DateTimeSetting);
722 }
723 else if (Value is TimeSpan TS)
724 {
725 if (!(Setting is TimeSpanUserSetting TimeSpanSetting))
726 {
727 if (!(Setting is null))
728 await Database.Delete(Setting);
729
730 TimeSpanSetting = null;
731 }
732
733 return await SetAsyncLocked(User, Key, TS, TimeSpanSetting);
734 }
735 else if (Value is Enum E)
736 {
737 if (!(Setting is EnumUserSetting EnumSetting))
738 {
739 if (!(Setting is null))
740 await Database.Delete(Setting);
741
742 EnumSetting = null;
743 }
744
745 return await SetAsyncLocked(User, Key, E, EnumSetting);
746 }
747 else
748 {
749 Type T = Value.GetType();
750 TypeInfo TI = T.GetTypeInfo();
751
752 if (!(TI.GetCustomAttribute(typeof(CollectionNameAttribute)) is null))
753 throw new InvalidOperationException("Object setting values cannot be stored separate collections. (CollectionName attribute found.)");
754
755 TypeNameAttribute TypeNameAttribute = TI.GetCustomAttribute<TypeNameAttribute>();
757 throw new InvalidOperationException("Full Type names must be serialized when persisting object setting values. (TypeName attribute.). Exceptions for the types: Boolean, Int64, String, DateTime, TimeSpan, Double.");
758 }
759 }
760
761 if (Setting is ObjectUserSetting ObjectSetting)
762 {
763 if (!RuntimeSettings.AreEqual(ObjectSetting.Value, Value))
764 {
765 ObjectSetting.Value = Value;
766 await Database.Update(ObjectSetting);
767
768 return true;
769 }
770 else
771 return false;
772 }
773 else
774 {
775 Setting = new ObjectUserSetting(User, Key, Value);
776 await Database.Insert(Setting);
777
778 return true;
779 }
780 }
781 }
782
783 #endregion
784
785 #region Delete Setting
786
793 public static async Task<bool> DeleteAsync(string User, string Key)
794 {
795 using (Semaphore Semaphore = await Semaphores.BeginWrite("usersetting:" + User + " " + Key))
796 {
797 int Count = await Database.Delete<UserSetting>(new FilterAnd(
798 new FilterFieldEqualTo("User", User),
799 new FilterFieldEqualTo("Key", Key)));
800
801 return Count > 0;
802 }
803 }
804
805 #endregion
806
807 #region Batch Get
808
816 public static Dictionary<string, object> GetWhere(Filter Filter, bool UserAsKey)
817 {
818 return GetWhereAsync(Filter, UserAsKey).Result;
819 }
820
828 public static async Task<Dictionary<string, object>> GetWhereAsync(Filter Filter, bool UserAsKey)
829 {
830 Dictionary<string, object> Result = new Dictionary<string, object>();
831
832 foreach (UserSetting Setting in await Database.Find<UserSetting>(Filter))
833 Result[UserAsKey ? Setting.User : Setting.Key] = Setting.GetValueObject();
834
835 return Result;
836 }
837
844 public static Dictionary<string, object> GetWhereKeyLikeRegEx(string User, string KeyPattern)
845 {
846 return GetWhere(new FilterAnd(
847 new FilterFieldEqualTo("User", User),
848 new FilterFieldLikeRegEx("Key", KeyPattern)), false);
849 }
850
857 public static Task<Dictionary<string, object>> GetWhereKeyLikeRegExAsync(string User, string KeyPattern)
858 {
859 return GetWhereAsync(new FilterAnd(
860 new FilterFieldEqualTo("User", User),
861 new FilterFieldLikeRegEx("Key", KeyPattern)), false);
862 }
863
871 public static Dictionary<string, object> GetWhereKeyLike(string User, string Key, string Wildcard)
872 {
873 return GetWhere(new FilterAnd(
874 new FilterFieldEqualTo("User", User),
875 new FilterFieldLikeRegEx("Key", Database.WildcardToRegex(Key, Wildcard))), false);
876 }
877
885 public static Task<Dictionary<string, object>> GetWhereKeyLikeAsync(string User, string Key, string Wildcard)
886 {
887 return GetWhereAsync(new FilterAnd(
888 new FilterFieldEqualTo("User", User),
889 new FilterFieldLikeRegEx("Key", Database.WildcardToRegex(Key, Wildcard))), false);
890 }
891
896 public static Dictionary<string, object> GetUserValues(string Key)
897 {
898 return GetWhere(new FilterFieldEqualTo("Key", Key), true);
899 }
900
905 public static Task<Dictionary<string, object>> GetUserValuesAsync(string Key)
906 {
907 return GetWhereAsync(new FilterFieldEqualTo("Key", Key), true);
908 }
909
910 #endregion
911
912 #region Batch Delete
913
919 public static int DeleteWhere(Filter Filter)
920 {
921 return DeleteWhereAsync(Filter).Result;
922 }
923
929 public static Task<int> DeleteWhereAsync(Filter Filter)
930 {
932 }
933
940 public static int DeleteWhereKeyLikeRegEx(string User, string KeyPattern)
941 {
942 return DeleteWhere(new FilterAnd(new FilterFieldEqualTo("User", User), new FilterFieldLikeRegEx("Key", KeyPattern)));
943 }
944
951 public static Task<int> DeleteWhereKeyLikeRegExAsync(string User, string KeyPattern)
952 {
953 return DeleteWhereAsync(new FilterAnd(new FilterFieldEqualTo("User", User), new FilterFieldLikeRegEx("Key", KeyPattern)));
954 }
955
963 public static int DeleteWhereKeyLike(string User, string Key, string Wildcard)
964 {
965 return DeleteWhere(new FilterAnd(new FilterFieldEqualTo("User", User),
966 new FilterFieldLikeRegEx("Key", Database.WildcardToRegex(Key, Wildcard))));
967 }
968
976 public static Task<int> DeleteWhereKeyLikeAsync(string User, string Key, string Wildcard)
977 {
978 return DeleteWhereAsync(new FilterAnd(new FilterFieldEqualTo("User", User),
979 new FilterFieldLikeRegEx("Key", Database.WildcardToRegex(Key, Wildcard))));
980 }
981
982 #endregion
983 }
984}
This attribute defines the name of the collection that will house objects of this type.
This attribute defines the name of the collection that will house objects of this type.
TypeNameSerialization TypeNameSerialization
How the type name should be serialized.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
Definition: Database.cs:21
static string WildcardToRegex(string s, string Wildcard)
Converts a wildcard string to a regular expression string.
Definition: Database.cs:2426
static async Task Update(object Object)
Updates an object in the database.
Definition: Database.cs:1211
static async Task Delete(object Object)
Deletes an object in the database.
Definition: Database.cs:1291
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
Definition: Database.cs:238
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Definition: Database.cs:97
This filter selects objects that conform to all child-filters provided.
Definition: FilterAnd.cs:10
This filter selects objects that have a named field equal to a given value.
This filter selects objects that have a named field matching a given regular expression.
Base class for all filter classes.
Definition: Filter.cs:15
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-valued setting.
Base abstract class for user settings.
Definition: UserSetting.cs:14
abstract object GetValueObject()
Gets the value of the setting, as an object.
Static class managing persistent user settings. User settings default to runtime settings if user-spe...
Definition: UserSettings.cs:18
static async Task< TimeSpan > GetAsync(string User, string Key, TimeSpan DefaultValue)
Gets a TimeSpan-valued setting.
static async Task< bool > SetAsync(string User, string Key, long Value)
Sets a long-valued setting.
static async Task< object > GetAsync(string User, string Key, object DefaultValue)
Gets a object-valued setting.
static TimeSpan Get(string User, string Key, TimeSpan DefaultValue)
Gets a TimeSpan-valued setting.
static bool Set(string User, string Key, TimeSpan Value)
Sets a TimeSpan-valued setting.
static async Task< long > GetAsync(string User, string Key, long DefaultValue)
Gets a long-valued setting.
static async Task< bool > SetAsync(string User, string Key, bool Value)
Sets a bool-valued setting.
static async Task< bool > SetAsync(string User, string Key, double Value)
Sets a double-valued setting.
static Task< Dictionary< string, object > > GetWhereKeyLikeRegExAsync(string User, string KeyPattern)
Gets available settings, matching a search filter, indexed by key.
static async Task< bool > SetAsync(string User, string Key, Enum Value)
Sets a Enum-valued setting.
static int DeleteWhereKeyLikeRegEx(string User, string KeyPattern)
Deletes available settings, matching a search filter.
static int DeleteWhere(Filter Filter)
Deletes available settings, matching a search filter.
static Dictionary< string, object > GetWhereKeyLikeRegEx(string User, string KeyPattern)
Gets available settings, matching a search filter, indexed by key.
static long Get(string User, string Key, long DefaultValue)
Gets a long-valued setting.
static async Task< Dictionary< string, object > > GetWhereAsync(Filter Filter, bool UserAsKey)
Gets available settings, matching a search filter.
static async Task< DateTime > GetAsync(string User, string Key, DateTime DefaultValue)
Gets a DateTime-valued setting.
static string Get(string User, string Key, string DefaultValue)
Gets a string-valued setting.
Definition: UserSettings.cs:28
static bool Get(string User, string Key, bool DefaultValue)
Gets a bool-valued setting.
static Task< int > DeleteWhereKeyLikeRegExAsync(string User, string KeyPattern)
Deletes available settings, matching a search filter.
static bool Set(string User, string Key, long Value)
Sets a long-valued setting.
static double Get(string User, string Key, double DefaultValue)
Gets a double-valued setting.
static Task< Dictionary< string, object > > GetWhereKeyLikeAsync(string User, string Key, string Wildcard)
Gets available settings, matching a search filter, indexed by key.
static async Task< bool > GetAsync(string User, string Key, bool DefaultValue)
Gets a bool-valued setting.
static async Task< bool > SetAsync(string User, string Key, string Value)
Sets a string-valued setting.
Definition: UserSettings.cs:77
static bool Set(string User, string Key, object Value)
Sets a object-valued setting.
static Dictionary< string, object > GetWhere(Filter Filter, bool UserAsKey)
Gets available settings, matching a search filter.
static async Task< string > GetAsync(string User, string Key, string DefaultValue)
Gets a string-valued setting.
Definition: UserSettings.cs:40
static bool Set(string User, string Key, DateTime Value)
Sets a DateTime-valued setting.
static async Task< bool > DeleteAsync(string User, string Key)
Deletes a runtime setting
static Dictionary< string, object > GetUserValues(string Key)
Gets available settings for a given key, indexed by user.
static object Get(string User, string Key, object DefaultValue)
Gets a object-valued setting.
static bool Set(string User, string Key, bool Value)
Sets a bool-valued setting.
static bool Set(string User, string Key, string Value)
Sets a string-valued setting.
Definition: UserSettings.cs:65
static bool Set(string User, string Key, Enum Value)
Sets a Enum-valued setting.
static async Task< double > GetAsync(string User, string Key, double DefaultValue)
Gets a double-valued setting.
static Dictionary< string, object > GetWhereKeyLike(string User, string Key, string Wildcard)
Gets available settings, matching a search filter, indexed by key.
static DateTime Get(string User, string Key, DateTime DefaultValue)
Gets a DateTime-valued setting.
static async Task< bool > SetAsync(string User, string Key, TimeSpan Value)
Sets a TimeSpan-valued setting.
static Task< int > DeleteWhereAsync(Filter Filter)
Deletes available settings, matching a search filter.
static Task< int > DeleteWhereKeyLikeAsync(string User, string Key, string Wildcard)
Deletes available settings, matching a search filter.
static async Task< Enum > GetAsync(string User, string Key, Enum DefaultValue)
Gets a Enum-valued setting.
static Task< Dictionary< string, object > > GetUserValuesAsync(string Key)
Gets available settings for a given key, indexed by user.
static int DeleteWhereKeyLike(string User, string Key, string Wildcard)
Deletes available settings, matching a search filter.
static Enum Get(string User, string Key, Enum DefaultValue)
Gets a Enum-valued setting.
static bool Set(string User, string Key, double Value)
Sets a double-valued setting.
static async Task< bool > SetAsync(string User, string Key, object Value)
Sets a object-valued setting.
static async Task< bool > SetAsync(string User, string Key, DateTime Value)
Sets a DateTime-valued setting.
Represents a named semaphore, i.e. an object, identified by a name, that allows single concurrent wri...
Definition: Semaphore.cs:19
Static class of application-wide semaphores that can be used to order access to editable objects.
Definition: Semaphores.cs:17
static async Task< Semaphore > BeginRead(string Key)
Waits until the semaphore identified by Key is ready for reading. Each call to BeginRead must be fol...
Definition: Semaphores.cs:54
static async Task< Semaphore > BeginWrite(string Key)
Waits until the semaphore identified by Key is ready for writing. Each call to BeginWrite must be fo...
Definition: Semaphores.cs:91
TypeNameSerialization
How the type name should be serialized.