aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/CompilerServices
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2015-06-10 09:40:30 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2015-06-10 09:40:31 +0200
commit578341c3e4410b803b65a739f950b103f3f0a95c (patch)
treef7e90e6b204b58db5ea8fa14bba5d7e53668c744 /src/CompilerServices
parent18e9dca6ea12f3f01a28c08f4b596268d0322a4f (diff)
- expandables
- events resolution stacking - Inlined template - xmlserialization debugging
Diffstat (limited to 'src/CompilerServices')
-rw-r--r--src/CompilerServices/CompilerServices.cs32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs
index 6f00d36d..065c6924 100644
--- a/src/CompilerServices/CompilerServices.cs
+++ b/src/CompilerServices/CompilerServices.cs
@@ -163,20 +163,28 @@ namespace go
MemberInfo miSrc = srcType.GetMember (binding.Value).FirstOrDefault();
//initialize target with actual value
+ object srcVal = null;
+ if (miSrc == null)
+ srcVal = _source;//if no member is provided for binding, source raw value is taken
+ else {
+ if (miSrc.MemberType == MemberTypes.Property)
+ srcVal = (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null);
+ else if (miSrc.MemberType == MemberTypes.Field)
+ srcVal = (miSrc as FieldInfo).GetValue (_source);
+ else
+ throw new Exception ("unandled source member type for binding");
+ }
if (miDst.MemberType == MemberTypes.Property) {
- if (miSrc == null)//if no member is provided for binding, source raw value is taken
- (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { _source });
- else if (miSrc.MemberType == MemberTypes.Property)
- (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null) });
- else if (miSrc.MemberType == MemberTypes.Field)
- (miDst as PropertyInfo).GetSetMethod ().Invoke (binding.Source, new object[] { (miSrc as FieldInfo).GetValue (_source) });
+ PropertyInfo piDst = miDst as PropertyInfo;
+ //TODO: handle other dest type conversions
+ if (piDst.PropertyType == typeof(string))
+ srcVal = srcVal.ToString ();
+ piDst.GetSetMethod ().Invoke (binding.Source, new object[] { srcVal });
} else if (miDst.MemberType == MemberTypes.Field) {
- if (miSrc == null)//if no member is provided for binding, source raw value is taken
- (miDst as FieldInfo).SetValue (binding.Source, _source );
- else if (miSrc.MemberType == MemberTypes.Property)
- (miDst as FieldInfo).SetValue (binding.Source, (miSrc as PropertyInfo).GetGetMethod ().Invoke (_source, null));
- else if (miSrc.MemberType == MemberTypes.Field)
- (miDst as FieldInfo).SetValue (binding.Source, (miSrc as FieldInfo).GetValue (_source));
+ FieldInfo fiDst = miDst as FieldInfo;
+ if (fiDst.FieldType == typeof(string))
+ srcVal = srcVal.ToString ();
+ fiDst.SetValue (binding.Source, srcVal );
}else
throw new Exception("unandled destination member type for binding");