Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HostSettings.cs
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4using System.Threading.Tasks;
10
12{
17 public static class HostSettings
18 {
19 #region String-valued settings
20
28 public static string Get(string Host, string Key, string DefaultValue)
29 {
30 return GetAsync(Host, Key, DefaultValue).Result;
31 }
32
40 public static async Task<string> GetAsync(string Host, string Key, string DefaultValue)
41 {
42 StringHostSetting Setting = await GetAsync<StringHostSetting>(Host, Key);
43 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
44 }
45
46 private static async Task<T> GetAsync<T>(string Host, string Key)
47 where T : class
48 {
49 using (Semaphore Semaphore = await Semaphores.BeginRead("hostsetting:" + Host + " " + Key))
50 {
51 T Setting = await Database.FindFirstDeleteRest<T>(new FilterAnd(
52 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
53
54 return Setting;
55 }
56 }
57
65 public static bool Set(string Host, string Key, string Value)
66 {
67 return SetAsync(Host, Key, Value).Result;
68 }
69
77 public static async Task<bool> SetAsync(string Host, string Key, string Value)
78 {
79 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
80 {
81 StringHostSetting Setting = await Database.FindFirstDeleteRest<StringHostSetting>(new FilterAnd(
82 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
83 return await SetAsyncLocked(Host, Key, Value, Setting);
84 }
85 }
86
87 private static async Task<bool> SetAsyncLocked(string Host, string Key, string Value, StringHostSetting Setting)
88 {
89 if (Setting is null)
90 {
91 Setting = new StringHostSetting(Host, 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 Host, string Key, long DefaultValue)
122 {
123 return GetAsync(Host, Key, DefaultValue).Result;
124 }
125
133 public static async Task<long> GetAsync(string Host, string Key, long DefaultValue)
134 {
135 Int64HostSetting Setting = await GetAsync<Int64HostSetting>(Host, Key);
136 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
137 }
138
146 public static bool Set(string Host, string Key, long Value)
147 {
148 return SetAsync(Host, Key, Value).Result;
149 }
150
158 public static async Task<bool> SetAsync(string Host, string Key, long Value)
159 {
160 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
161 {
162 Int64HostSetting Setting = await Database.FindFirstDeleteRest<Int64HostSetting>(new FilterAnd(
163 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
164 return await SetAsyncLocked(Host, Key, Value, Setting);
165 }
166 }
167
168 private static async Task<bool> SetAsyncLocked(string Host, string Key, long Value, Int64HostSetting Setting)
169 {
170 if (Setting is null)
171 {
172 Setting = new Int64HostSetting(Host, 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 Host, string Key, bool DefaultValue)
203 {
204 return GetAsync(Host, Key, DefaultValue).Result;
205 }
206
214 public static async Task<bool> GetAsync(string Host, string Key, bool DefaultValue)
215 {
216 BooleanHostSetting Setting = await GetAsync<BooleanHostSetting>(Host, Key);
217 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
218 }
219
227 public static bool Set(string Host, string Key, bool Value)
228 {
229 return SetAsync(Host, Key, Value).Result;
230 }
231
239 public static async Task<bool> SetAsync(string Host, string Key, bool Value)
240 {
241 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
242 {
243 BooleanHostSetting Setting = await Database.FindFirstDeleteRest<BooleanHostSetting>(new FilterAnd(
244 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
245 return await SetAsyncLocked(Host, Key, Value, Setting);
246 }
247 }
248
249 private static async Task<bool> SetAsyncLocked(string Host, string Key, bool Value, BooleanHostSetting Setting)
250 {
251 if (Setting is null)
252 {
253 Setting = new BooleanHostSetting(Host, 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 Host, string Key, DateTime DefaultValue)
284 {
285 return GetAsync(Host, Key, DefaultValue).Result;
286 }
287
295 public static async Task<DateTime> GetAsync(string Host, string Key, DateTime DefaultValue)
296 {
297 DateTimeHostSetting Setting = await GetAsync<DateTimeHostSetting>(Host, Key);
298 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
299 }
300
308 public static bool Set(string Host, string Key, DateTime Value)
309 {
310 return SetAsync(Host, Key, Value).Result;
311 }
312
320 public static async Task<bool> SetAsync(string Host, string Key, DateTime Value)
321 {
322 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
323 {
324 DateTimeHostSetting Setting = await Database.FindFirstDeleteRest<DateTimeHostSetting>(new FilterAnd(
325 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
326 return await SetAsyncLocked(Host, Key, Value, Setting);
327 }
328 }
329
330 private static async Task<bool> SetAsyncLocked(string Host, string Key, DateTime Value, DateTimeHostSetting Setting)
331 {
332 if (Setting is null)
333 {
334 Setting = new DateTimeHostSetting(Host, 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 Host, string Key, TimeSpan DefaultValue)
365 {
366 return GetAsync(Host, Key, DefaultValue).Result;
367 }
368
376 public static async Task<TimeSpan> GetAsync(string Host, string Key, TimeSpan DefaultValue)
377 {
378 TimeSpanHostSetting Setting = await GetAsync<TimeSpanHostSetting>(Host, Key);
379 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
380 }
381
389 public static bool Set(string Host, string Key, TimeSpan Value)
390 {
391 return SetAsync(Host, Key, Value).Result;
392 }
393
401 public static async Task<bool> SetAsync(string Host, string Key, TimeSpan Value)
402 {
403 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
404 {
405 TimeSpanHostSetting Setting = await Database.FindFirstDeleteRest<TimeSpanHostSetting>(new FilterAnd(
406 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
407 return await SetAsyncLocked(Host, Key, Value, Setting);
408 }
409 }
410
411 private static async Task<bool> SetAsyncLocked(string Host, string Key, TimeSpan Value, TimeSpanHostSetting Setting)
412 {
413 if (Setting is null)
414 {
415 Setting = new TimeSpanHostSetting(Host, 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 Host, string Key, double DefaultValue)
446 {
447 return GetAsync(Host, Key, DefaultValue).Result;
448 }
449
457 public static async Task<double> GetAsync(string Host, string Key, double DefaultValue)
458 {
459 DoubleHostSetting Setting = await GetAsync<DoubleHostSetting>(Host, Key);
460 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
461 }
462
470 public static bool Set(string Host, string Key, double Value)
471 {
472 return SetAsync(Host, Key, Value).Result;
473 }
474
482 public static async Task<bool> SetAsync(string Host, string Key, double Value)
483 {
484 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
485 {
486 DoubleHostSetting Setting = await Database.FindFirstDeleteRest<DoubleHostSetting>(new FilterAnd(
487 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
488 return await SetAsyncLocked(Host, Key, Value, Setting);
489 }
490 }
491
492 private static async Task<bool> SetAsyncLocked(string Host, string Key, double Value, DoubleHostSetting Setting)
493 {
494 if (Setting is null)
495 {
496 Setting = new DoubleHostSetting(Host, 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 Host, string Key, Enum DefaultValue)
527 {
528 return GetAsync(Host, Key, DefaultValue).Result;
529 }
530
538 public static async Task<Enum> GetAsync(string Host, string Key, Enum DefaultValue)
539 {
540 EnumHostSetting Setting = await GetAsync<EnumHostSetting>(Host, Key);
541 return Setting?.Value ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
542 }
543
551 public static bool Set(string Host, string Key, Enum Value)
552 {
553 return SetAsync(Host, Key, Value).Result;
554 }
555
563 public static async Task<bool> SetAsync(string Host, string Key, Enum Value)
564 {
565 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
566 {
567 EnumHostSetting Setting = await Database.FindFirstDeleteRest<EnumHostSetting>(new FilterAnd(
568 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
569 return await SetAsyncLocked(Host, Key, Value, Setting);
570 }
571 }
572
573 private static async Task<bool> SetAsyncLocked(string Host, string Key, Enum Value, EnumHostSetting Setting)
574 {
575 if (Setting is null)
576 {
577 Setting = new EnumHostSetting(Host, 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 Host, string Key, object DefaultValue)
608 {
609 return GetAsync(Host, Key, DefaultValue).Result;
610 }
611
619 public static async Task<object> GetAsync(string Host, string Key, object DefaultValue)
620 {
621 HostSetting Setting = await GetAsync<HostSetting>(Host, Key);
622 return Setting?.GetValueObject() ?? await RuntimeSettings.GetAsync(Key, DefaultValue);
623 }
624
632 public static bool Set(string Host, string Key, object Value)
633 {
634 return SetAsync(Host, Key, Value).Result;
635 }
636
644 public static async Task<bool> SetAsync(string Host, string Key, object Value)
645 {
646 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
647 {
648 HostSetting Setting = await Database.FindFirstDeleteRest<HostSetting>(new FilterAnd(
649 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key)));
650
651 if (Value is null)
652 {
653 if (!(Setting is ObjectHostSetting))
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 StringHostSetting StringSetting))
666 {
667 if (!(Setting is null))
668 await Database.Delete(Setting);
669
670 StringSetting = null;
671 }
672
673 return await SetAsyncLocked(Host, Key, s, StringSetting);
674 }
675 else if (Value is long l)
676 {
677 if (!(Setting is Int64HostSetting Int64Setting))
678 {
679 if (!(Setting is null))
680 await Database.Delete(Setting);
681
682 Int64Setting = null;
683 }
684
685 return await SetAsyncLocked(Host, Key, l, Int64Setting);
686 }
687 else if (Value is double d)
688 {
689 if (!(Setting is DoubleHostSetting DoubleSetting))
690 {
691 if (!(Setting is null))
692 await Database.Delete(Setting);
693
694 DoubleSetting = null;
695 }
696
697 return await SetAsyncLocked(Host, Key, d, DoubleSetting);
698 }
699 else if (Value is bool b)
700 {
701 if (!(Setting is BooleanHostSetting BooleanSetting))
702 {
703 if (!(Setting is null))
704 await Database.Delete(Setting);
705
706 BooleanSetting = null;
707 }
708
709 return await SetAsyncLocked(Host, Key, b, BooleanSetting);
710 }
711 else if (Value is DateTime TP)
712 {
713 if (!(Setting is DateTimeHostSetting DateTimeSetting))
714 {
715 if (!(Setting is null))
716 await Database.Delete(Setting);
717
718 DateTimeSetting = null;
719 }
720
721 return await SetAsyncLocked(Host, Key, TP, DateTimeSetting);
722 }
723 else if (Value is TimeSpan TS)
724 {
725 if (!(Setting is TimeSpanHostSetting TimeSpanSetting))
726 {
727 if (!(Setting is null))
728 await Database.Delete(Setting);
729
730 TimeSpanSetting = null;
731 }
732
733 return await SetAsyncLocked(Host, Key, TS, TimeSpanSetting);
734 }
735 else if (Value is Enum E)
736 {
737 if (!(Setting is EnumHostSetting EnumSetting))
738 {
739 if (!(Setting is null))
740 await Database.Delete(Setting);
741
742 EnumSetting = null;
743 }
744
745 return await SetAsyncLocked(Host, 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 ObjectHostSetting ObjectSetting)
762 {
763 if (((ObjectSetting.Value is null) ^ (Value is null)) || !ObjectSetting.Value.Equals(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 ObjectHostSetting(Host, 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 Host, string Key)
794 {
795 using (Semaphore Semaphore = await Semaphores.BeginWrite("hostsetting:" + Host + " " + Key))
796 {
797 foreach (HostSetting _ in await Database.FindDelete<HostSetting>(new FilterAnd(
798 new FilterFieldEqualTo("Host", Host), new FilterFieldEqualTo("Key", Key))))
799 {
800 return true;
801 }
802
803 return false;
804 }
805 }
806
807 #endregion
808
809 #region Batch Get
810
818 public static Dictionary<string, object> GetWhere(Filter Filter, bool HostAsKey)
819 {
820 return GetWhereAsync(Filter, HostAsKey).Result;
821 }
822
830 public static async Task<Dictionary<string, object>> GetWhereAsync(Filter Filter, bool HostAsKey)
831 {
832 Dictionary<string, object> Result = new Dictionary<string, object>();
833
834 foreach (HostSetting Setting in await Database.Find<HostSetting>(Filter))
835 Result[HostAsKey ? Setting.Host : Setting.Key] = Setting.GetValueObject();
836
837 return Result;
838 }
839
846 public static Dictionary<string, object> GetWhereKeyLikeRegEx(string Host, string KeyPattern)
847 {
848 return GetWhere(new FilterAnd(
849 new FilterFieldEqualTo("Host", Host),
850 new FilterFieldLikeRegEx("Key", KeyPattern)), false);
851 }
852
859 public static Task<Dictionary<string, object>> GetWhereKeyLikeRegExAsync(string Host, string KeyPattern)
860 {
861 return GetWhereAsync(new FilterAnd(
862 new FilterFieldEqualTo("Host", Host),
863 new FilterFieldLikeRegEx("Key", KeyPattern)), false);
864 }
865
873 public static Dictionary<string, object> GetWhereKeyLike(string Host, string Key, string Wildcard)
874 {
875 return GetWhere(new FilterAnd(
876 new FilterFieldEqualTo("Host", Host),
877 new FilterFieldLikeRegEx("Key", Database.WildcardToRegex(Key, Wildcard))), false);
878 }
879
887 public static Task<Dictionary<string, object>> GetWhereKeyLikeAsync(string Host, string Key, string Wildcard)
888 {
889 return GetWhereAsync(new FilterAnd(
890 new FilterFieldEqualTo("Host", Host),
891 new FilterFieldLikeRegEx("Key", Database.WildcardToRegex(Key, Wildcard))), false);
892 }
893
898 public static Dictionary<string, object> GetHostValues(string Key)
899 {
900 return GetWhere(new FilterFieldEqualTo("Key", Key), true);
901 }
902
907 public static Task<Dictionary<string, object>> GetHostValuesAsync(string Key)
908 {
909 return GetWhereAsync(new FilterFieldEqualTo("Key", Key), true);
910 }
911
912 #endregion
913
914 #region Batch Delete
915
921 public static int DeleteWhere(Filter Filter)
922 {
923 return DeleteWhereAsync(Filter).Result;
924 }
925
931 public static async Task<int> DeleteWhereAsync(Filter Filter)
932 {
933 int Result = 0;
934
935 foreach (HostSetting Setting in await Database.FindDelete<HostSetting>(Filter))
936 Result++;
937
938 return Result;
939 }
940
947 public static int DeleteWhereKeyLikeRegEx(string Host, string KeyPattern)
948 {
949 return DeleteWhere(new FilterAnd(new FilterFieldEqualTo("Host", Host), new FilterFieldLikeRegEx("Key", KeyPattern)));
950 }
951
958 public static Task<int> DeleteWhereKeyLikeRegExAsync(string Host, string KeyPattern)
959 {
960 return DeleteWhereAsync(new FilterAnd(new FilterFieldEqualTo("Host", Host), new FilterFieldLikeRegEx("Key", KeyPattern)));
961 }
962
970 public static int DeleteWhereKeyLike(string Host, string Key, string Wildcard)
971 {
972 return DeleteWhere(new FilterAnd(new FilterFieldEqualTo("Host", Host),
973 new FilterFieldLikeRegEx("Key", Database.WildcardToRegex(Key, Wildcard))));
974 }
975
983 public static Task<int> DeleteWhereKeyLikeAsync(string Host, string Key, string Wildcard)
984 {
985 return DeleteWhereAsync(new FilterAnd(new FilterFieldEqualTo("Host", Host),
986 new FilterFieldLikeRegEx("Key", Database.WildcardToRegex(Key, Wildcard))));
987 }
988
989 #endregion
990 }
991}
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:19
static Task< IEnumerable< object > > FindDelete(string Collection, params string[] SortOrder)
Finds objects in a given collection and deletes them in the same atomic operation.
Definition: Database.cs:879
static string WildcardToRegex(string s, string Wildcard)
Converts a wildcard string to a regular expression string.
Definition: Database.cs:1631
static async Task Update(object Object)
Updates an object in the database.
Definition: Database.cs:626
static async Task Delete(object Object)
Deletes an object in the database.
Definition: Database.cs:717
static Task< IEnumerable< object > > Find(string Collection, params string[] SortOrder)
Finds objects in a given collection.
Definition: Database.cs:247
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
Definition: Database.cs:95
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
Base abstract class for host settings.
Definition: HostSetting.cs:15
abstract object GetValueObject()
Gets the value of the setting, as an object.
Static class managing persistent host settings. Host settings default to runtime settings if host-spe...
Definition: HostSettings.cs:18
static Dictionary< string, object > GetWhereKeyLikeRegEx(string Host, string KeyPattern)
Gets available settings, matching a search filter, indexed by key.
static async Task< bool > SetAsync(string Host, string Key, Enum Value)
Sets a Enum-valued setting.
static Dictionary< string, object > GetHostValues(string Key)
Gets available settings for a given key, indexed by host.
static Task< Dictionary< string, object > > GetWhereKeyLikeAsync(string Host, string Key, string Wildcard)
Gets available settings, matching a search filter, indexed by key.
static Task< Dictionary< string, object > > GetWhereKeyLikeRegExAsync(string Host, string KeyPattern)
Gets available settings, matching a search filter, indexed by key.
static double Get(string Host, string Key, double DefaultValue)
Gets a double-valued setting.
static async Task< double > GetAsync(string Host, string Key, double DefaultValue)
Gets a double-valued setting.
static bool Set(string Host, string Key, string Value)
Sets a string-valued setting.
Definition: HostSettings.cs:65
static async Task< bool > SetAsync(string Host, string Key, long Value)
Sets a long-valued setting.
static int DeleteWhereKeyLikeRegEx(string Host, string KeyPattern)
Deletes available settings, matching a search filter.
static TimeSpan Get(string Host, string Key, TimeSpan DefaultValue)
Gets a TimeSpan-valued setting.
static async Task< Enum > GetAsync(string Host, string Key, Enum DefaultValue)
Gets a Enum-valued setting.
static async Task< bool > GetAsync(string Host, string Key, bool DefaultValue)
Gets a bool-valued setting.
static async Task< bool > SetAsync(string Host, string Key, double Value)
Sets a double-valued setting.
static Task< Dictionary< string, object > > GetHostValuesAsync(string Key)
Gets available settings for a given key, indexed by host.
static bool Set(string Host, string Key, long Value)
Sets a long-valued setting.
static Dictionary< string, object > GetWhereKeyLike(string Host, string Key, string Wildcard)
Gets available settings, matching a search filter, indexed by key.
static bool Set(string Host, string Key, object Value)
Sets a object-valued setting.
static bool Set(string Host, string Key, bool Value)
Sets a bool-valued setting.
static async Task< DateTime > GetAsync(string Host, string Key, DateTime DefaultValue)
Gets a DateTime-valued setting.
static async Task< string > GetAsync(string Host, string Key, string DefaultValue)
Gets a string-valued setting.
Definition: HostSettings.cs:40
static Enum Get(string Host, string Key, Enum DefaultValue)
Gets a Enum-valued setting.
static async Task< long > GetAsync(string Host, string Key, long DefaultValue)
Gets a long-valued setting.
static async Task< bool > SetAsync(string Host, string Key, object Value)
Sets a object-valued setting.
static async Task< TimeSpan > GetAsync(string Host, string Key, TimeSpan DefaultValue)
Gets a TimeSpan-valued setting.
static Task< int > DeleteWhereKeyLikeRegExAsync(string Host, string KeyPattern)
Deletes available settings, matching a search filter.
static Dictionary< string, object > GetWhere(Filter Filter, bool HostAsKey)
Gets available settings, matching a search filter.
static bool Set(string Host, string Key, TimeSpan Value)
Sets a TimeSpan-valued setting.
static Task< int > DeleteWhereKeyLikeAsync(string Host, string Key, string Wildcard)
Deletes available settings, matching a search filter.
static string Get(string Host, string Key, string DefaultValue)
Gets a string-valued setting.
Definition: HostSettings.cs:28
static long Get(string Host, string Key, long DefaultValue)
Gets a long-valued setting.
static DateTime Get(string Host, string Key, DateTime DefaultValue)
Gets a DateTime-valued setting.
static async Task< int > DeleteWhereAsync(Filter Filter)
Deletes available settings, matching a search filter.
static async Task< bool > DeleteAsync(string Host, string Key)
Deletes a runtime setting
static bool Set(string Host, string Key, double Value)
Sets a double-valued setting.
static async Task< Dictionary< string, object > > GetWhereAsync(Filter Filter, bool HostAsKey)
Gets available settings, matching a search filter.
static async Task< object > GetAsync(string Host, string Key, object DefaultValue)
Gets a object-valued setting.
static async Task< bool > SetAsync(string Host, string Key, TimeSpan Value)
Sets a TimeSpan-valued setting.
static int DeleteWhereKeyLike(string Host, string Key, string Wildcard)
Deletes available settings, matching a search filter.
static async Task< bool > SetAsync(string Host, string Key, DateTime Value)
Sets a DateTime-valued setting.
static bool Get(string Host, string Key, bool DefaultValue)
Gets a bool-valued setting.
static async Task< bool > SetAsync(string Host, string Key, string Value)
Sets a string-valued setting.
Definition: HostSettings.cs:77
static async Task< bool > SetAsync(string Host, string Key, bool Value)
Sets a bool-valued setting.
static bool Set(string Host, string Key, DateTime Value)
Sets a DateTime-valued setting.
static bool Set(string Host, string Key, Enum Value)
Sets a Enum-valued setting.
static int DeleteWhere(Filter Filter)
Deletes available settings, matching a search filter.
static object Get(string Host, string Key, object DefaultValue)
Gets a object-valued setting.
Static class managing persistent settings.
static async Task< string > GetAsync(string Key, string DefaultValue)
Gets a string-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:16
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:53
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:90
TypeNameSerialization
How the type name should be serialized.