|
@@ -79,6 +79,14 @@ namespace Hotline.Caching.Services
|
|
|
|
|
|
try
|
|
|
{
|
|
|
+ var targetType = typeof(T);
|
|
|
+ if (targetType.IsEnum)
|
|
|
+ {
|
|
|
+ if (value is string strValue)
|
|
|
+ return (T)Enum.Parse(targetType, strValue, ignoreCase: true);
|
|
|
+ else
|
|
|
+ return (T)Enum.ToObject(targetType, value);
|
|
|
+ }
|
|
|
return (T)Convert.ChangeType(value, typeof(T));
|
|
|
}
|
|
|
catch (InvalidCastException e)
|