mirror of
https://github.com/n00mkrad/flowframes.git
synced 2025-12-22 03:09:28 +01:00
Completely revamped output settings (quality settings WIP)
This commit is contained in:
38
Code/MiscUtils/ParseUtils.cs
Normal file
38
Code/MiscUtils/ParseUtils.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Flowframes.MiscUtils
|
||||
{
|
||||
internal class ParseUtils
|
||||
{
|
||||
public static TEnum GetEnum<TEnum>(string str, bool ignoreCase = true, Dictionary<string, string> stringMap = null) where TEnum : Enum
|
||||
{
|
||||
if (stringMap == null)
|
||||
stringMap = new Dictionary<string, string>();
|
||||
|
||||
str = stringMap.Get(str, true, true);
|
||||
var values = Enum.GetValues(typeof(TEnum)).Cast<TEnum>();
|
||||
|
||||
foreach (var entry in values)
|
||||
{
|
||||
string entryString = stringMap.Get(entry.ToString(), true);
|
||||
|
||||
if (ignoreCase)
|
||||
{
|
||||
if (entryString.Lower() == str.Lower())
|
||||
return entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entryString == str)
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
return (TEnum)(object)(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user