1
This commit is contained in:
@@ -97,6 +97,22 @@ namespace BITKit
|
||||
throw new NullReferenceException($"没有找到{typeof(T).Name}");
|
||||
}
|
||||
}
|
||||
public static bool TryGet<T>(out T value)
|
||||
{
|
||||
lock (dictionary)
|
||||
{
|
||||
if (dictionary.TryGetValue(typeof(T), out var obj))
|
||||
{
|
||||
if (obj is T i)
|
||||
{
|
||||
value = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
value = default;
|
||||
return false;
|
||||
}
|
||||
public static async Task<Interface> GetAsync<Interface>()
|
||||
{
|
||||
await TaskHelper.WaitUntil(() => dictionary.ContainsKey(typeof(Interface)) && dictionary[typeof(Interface) ]is not null);
|
||||
|
Reference in New Issue
Block a user