Skip to content

Commit 43d5fb9

Browse files
authored
Merge pull request #15 from jacqueskang/default-value-converter-reinforce
last-ditch effort for type convertion
2 parents b370daf + c302b4c commit 43d5fb9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/JKang.IpcServiceFramework.Core/Services/DefaultValueConverter.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Newtonsoft.Json.Linq;
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Linq;
23
using System;
34

45
namespace JKang.IpcServiceFramework.Services
@@ -66,11 +67,19 @@ public bool TryConvert(object origValue, Type destType, out object destValue)
6667
destValue = Convert.ChangeType(origValue, destType);
6768
return true;
6869
}
69-
catch (Exception)
70+
catch
71+
{ }
72+
73+
try
7074
{
71-
destValue = null;
72-
return false;
75+
destValue = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(origValue), destType);
76+
return true;
7377
}
78+
catch
79+
{ }
80+
81+
destValue = null;
82+
return false;
7483
}
7584
}
7685
}

0 commit comments

Comments
 (0)