Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit ed9cf8e7 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

corrected introduced bug in enumhelper (character "-" makes problems...

corrected introduced bug in enumhelper (character "-" makes problems sometimes, but in other times its needed)
parent 9f3d9875
No related branches found
No related tags found
No related merge requests found
......@@ -38,8 +38,11 @@ namespace TUGraz.VectoCommon.Utils
{
public static class EnumHelper
{
public static T ParseEnum<T>(this string s, bool ignoreCase = true) =>
(T)Enum.Parse(typeof(T), Regex.Replace(s, "[^a-zA-Z0-9_-]", ""), ignoreCase);
public static T ParseEnum<T>(this string s, bool ignoreCase = true) =>
(T)Enum.Parse(typeof(T),
s.StartsWith("-")
? Regex.Replace(s, "[^a-zA-Z0-9_-]", "")
: Regex.Replace(s, "[^a-zA-Z0-9_]", ""), ignoreCase);
public static T ParseEnum<T>(this object o, bool ignoreCase = true) =>
o is string s ? ParseEnum<T>(s, ignoreCase) : (T)o;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment