From: jpbruyere Date: Sat, 12 Sep 2015 16:38:45 +0000 (+0200) Subject: Allow one way binding with MemberLess value passed as string with ValueChanched event X-Git-Tag: 0.2~35 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=8624ae1ead48d7ddc206486db0c4fc024afac703;p=jp%2Fcrow.git Allow one way binding with MemberLess value passed as string with ValueChanched event --- diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 1aaeac99..f383c8ee 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -322,13 +322,19 @@ namespace go PropertyInfo piTarget = dstType.GetProperty(binding.MemberName); Type srcValueType = null; + + if (miSrc == null) + //this allow memberless binding with only a name passed as MemberName + //but the value passed has to be a string + srcValueType = typeof(string); + else{ if (miSrc.MemberType == MemberTypes.Property) srcValueType = (miSrc as PropertyInfo).PropertyType; else if (miSrc.MemberType == MemberTypes.Field) srcValueType = (miSrc as FieldInfo).FieldType; else throw new Exception("unandled source member type for binding"); - + } if (!srcValueType.IsValueType) il.Emit(OpCodes.Castclass, srcValueType); else if (piTarget.PropertyType != srcValueType)