Skip to content

Commit 1be677a

Browse files
authored
Adding deserialization support for Enums
Fix: deserializing a entity containing enum throw "InvalidCastException: Invalid cast from 'System.String' to '<EnumType>'."
1 parent 87f6724 commit 1be677a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

FileContextCore/Serializer/SerializerHelper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public static object Deserialize(this string input, Type type)
4848
return arr.ToArray();
4949
}
5050

51+
if (type.IsEnum)
52+
{
53+
return Enum.Parse(type, input);
54+
}
5155

5256
return Convert.ChangeType(input, type, CultureInfo.InvariantCulture);
5357
}

0 commit comments

Comments
 (0)