1
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user