Commit 38d6c5e2 authored by Vadim Zaslavsky's avatar Vadim Zaslavsky Committed by mrbean-bremen
Browse files

Case insensitive enum parsing fixed

parent b07559d6
...@@ -305,13 +305,16 @@ namespace Svg ...@@ -305,13 +305,16 @@ namespace Svg
[CLSCompliant(false)] [CLSCompliant(false)]
public static bool TryParse<TEnum>(string value, out TEnum result) where TEnum : struct, IConvertible public static bool TryParse<TEnum>(string value, out TEnum result) where TEnum : struct, IConvertible
{ {
var retValue = value == null ? try
false : {
Enum.IsDefined(typeof(TEnum), value); result = (TEnum)Enum.Parse(typeof(TEnum), value, true);
result = retValue ? return true;
(TEnum)Enum.Parse(typeof(TEnum), value) : }
default(TEnum); catch
return retValue; {
result = default(TEnum);
return false;
}
} }
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment