mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
17 lines
366 B
C#
17 lines
366 B
C#
namespace AssetRipper.AssemblyDumper.Extensions;
|
|
|
|
internal static class DictionaryExtensions
|
|
{
|
|
public static TValue GetOrAdd<TKey, TValue>(this Dictionary<TKey, TValue> dict, TKey key)
|
|
where TKey : notnull
|
|
where TValue : new()
|
|
{
|
|
if (!dict.TryGetValue(key, out TValue? value))
|
|
{
|
|
value = new TValue();
|
|
dict.Add(key, value);
|
|
}
|
|
return value;
|
|
}
|
|
}
|