Initial commit of new UI c# component
This commit is contained in:
21
Il2CppInspector.Redux.GUI/DictionaryExtensions.cs
Normal file
21
Il2CppInspector.Redux.GUI/DictionaryExtensions.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace Il2CppInspector.Redux.GUI;
|
||||
|
||||
public static class DictionaryExtensions
|
||||
{
|
||||
public static bool GetAsBooleanOrDefault(this Dictionary<string, string> dict, string key, bool defaultValue)
|
||||
{
|
||||
if (dict.TryGetValue(key, out var value) && bool.TryParse(value, out var boolResult))
|
||||
return boolResult;
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static T GetAsEnumOrDefault<T>(this Dictionary<string, string> dict, string key, T defaultValue)
|
||||
where T : struct, Enum
|
||||
{
|
||||
if (dict.TryGetValue(key, out var value) && Enum.TryParse<T>(value, out var enumResult))
|
||||
return enumResult;
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user