This commit is contained in:
CortexCore
2024-04-16 04:15:06 +08:00
parent b673a9438d
commit 0362b2c606
183 changed files with 5695 additions and 1453 deletions

View File

@@ -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);