0
0
mirror of https://github.com/sp-tarkov/launcher.git synced 2025-02-13 09:30:45 -05:00
launcher/project/Aki.Launcher.Base/Extensions/DictionaryExtensions.cs
2023-03-03 19:25:33 +00:00

38 lines
850 B
C#

/* DictionaryExtension.cs
* License: NCSA Open Source License
*
* Copyright: Merijn Hendriks
* AUTHORS:
* waffle.lord
*/
using System.Collections.Generic;
using System.Linq;
namespace Aki.Launcher.Extensions
{
public static class DictionaryExtensions
{
public static TKey GetKeyByValue<TKey, TValue>(this Dictionary<TKey, TValue> Dic, TValue value)
{
List<TKey> Keys = Dic.Keys.ToList();
for (int x = 0; x < Keys.Count(); x++)
{
TValue tempValue;
if (Dic.TryGetValue(Keys[x], out tempValue))
{
if (tempValue != null && tempValue.Equals(value))
{
return Keys[x];
}
}
}
return default;
}
}
}