aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/CompilerServices
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-11-04 17:57:24 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2017-11-04 17:57:24 +0100
commit2b8c62055a7bc7a44df73965044b80c9cc572fe7 (patch)
treed56aefd7f5cd8e9fe1f80b7957bba6c7578721f3 /src/CompilerServices
parentdc8d870b76c445b6ef979ff58c2260e88793d167 (diff)
add string to primType in binding SetValueByReflexion
Diffstat (limited to 'src/CompilerServices')
-rw-r--r--src/CompilerServices/CompilerServices.cs29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs
index 5409aa5e..827ee617 100644
--- a/src/CompilerServices/CompilerServices.cs
+++ b/src/CompilerServices/CompilerServices.cs
@@ -295,18 +295,25 @@ namespace Crow
else if (miDest.MemberType == MemberTypes.Field)
destType =(miDest as FieldInfo).FieldType;
- if (value != null) {
- if (destType == TObject)//TODO: check that test of destType is not causing problems
- convertedVal = value;
- else {
- origType = value.GetType ();
- if (destType.IsAssignableFrom (origType))
- convertedVal = Convert.ChangeType (value, destType);
- else if (origType.IsPrimitive & destType.IsPrimitive)
- convertedVal = GetConvertMethod (destType).Invoke (null, new Object[] { value });
- else
- convertedVal = getImplicitOp (origType, destType).Invoke (value, null);
+ try {
+ if (value != null) {
+ if (destType == TObject)//TODO: check that test of destType is not causing problems
+ convertedVal = value;
+ else {
+ origType = value.GetType ();
+ if (destType.IsAssignableFrom (origType))
+ convertedVal = Convert.ChangeType (value, destType);
+ else if (origType == typeof(string) & destType.IsPrimitive)
+ convertedVal = Convert.ChangeType(value, destType);
+ else if (origType.IsPrimitive & destType.IsPrimitive)
+ convertedVal = GetConvertMethod (destType).Invoke (null, new Object[] { value });
+ else
+ convertedVal = getImplicitOp (origType, destType).Invoke (value, null);
+ }
}
+ } catch (Exception ex) {
+ Debug.WriteLine (ex.ToString ());
+ return;
}
if (miDest.MemberType == MemberTypes.Property)