Skip to content

Commit

Permalink
Add type conversion fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
JLChnToZ committed May 30, 2023
1 parent bcde41d commit 4ecec2e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions JLChnToZ.CommonUtils.Dynamic/Utilites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ internal static class Utilites {
public static object InternalUnwrap(object obj, Binder binder = null, Type requestedType = null) {
if (obj == null) return null;
if (obj is Limitless limitObj) obj = limitObj.target;
if (binder != null && requestedType != null)
if (requestedType != null) {
try {
return binder.ChangeType(obj, requestedType, null);
if (binder != null) return binder.ChangeType(obj, requestedType, null);
} catch {}
try {
return Convert.ChangeType(obj, requestedType);
} catch {}
}
return obj;
}

Expand Down

0 comments on commit 4ecec2e

Please sign in to comment.