This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -50,6 +50,17 @@ namespace BITKit
key = Generic<T>.GetVariable(key);
events.Get(key).Remove(action);
}
public static void Set<T>(string key, Func<T> factory)
{
key = Generic<T>.GetVariable(key);
dictionary.AddOrUpdate(key,factory, AddOrUpdate);
return;
Func<T> AddOrUpdate(string _key,object current)
{
return factory;
}
}
public static void Set<T>(string key, T value)
{
key = Generic<T>.GetVariable(key);
@@ -91,9 +102,12 @@ namespace BITKit
key = Generic<T>.GetVariable(key);
if (dictionary.TryGetValue(key, out var value))
{
if (value is T t)
switch (value)
{
return t;
case T t:
return t;
case Func<T> func:
return func.Invoke();
}
}
return default;