Fixed issue where singleton configuration cache was blocking creation of new components

This commit is contained in:
TheXamlGuy
2024-10-07 23:12:22 +01:00
parent 1c28659eac
commit f47e3deee9
6 changed files with 51 additions and 53 deletions
+6 -5
View File
@@ -2,16 +2,17 @@
namespace Toolkit.Foundation;
public static class ConfigurationCache
public class ConfigurationCache :
IConfigurationCache
{
private static readonly ConcurrentDictionary<string, object?> cache = new();
private readonly ConcurrentDictionary<string, object?> cache = new();
public static void Set<TConfiguration>(string section,
public void Set<TConfiguration>(string section,
TConfiguration configuration) => cache[section] = configuration;
public static bool Remove(string section) => cache.TryRemove(section, out _);
public bool Remove(string section) => cache.TryRemove(section, out _);
public static bool TryGet<TConfiguration>(string section,
public bool TryGet<TConfiguration>(string section,
out TConfiguration? configuration)
{
if (cache.TryGetValue(section, out object? cachedValue))