w.Run (30);
}
}
-
+ public object data = "datas";
+ public object Datas {
+ get { return data; }
+ }
+ void onSetDataToNull (object sender, MouseButtonEventArgs e) {
+ data = null;
+ NotifyValueChanged ("Datas", null);
+ }
public override void OnLoad ()
{
+ //testFiles = new string [] { @"Interfaces/Divers/testBind0.crow" };
testFiles = new string [] { @"Interfaces/Divers/testCombobox.crow" };
testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/GraphicObject", "*.crow")).ToArray ();
//testFiles = testFiles.Concat (Directory.GetFiles (@"Interfaces/basicTests", "*.crow")).ToArray ();
return;
if (Bindings.Count == 0)
return;
-#if DEBUG_BINDING
- Debug.WriteLine ("Resolve Bindings => " + this.ToString ());
-#endif
+//#if DEBUG_BINDING
+// Debug.WriteLine ("Resolve Bindings => " + this.ToString ());
+//#endif
//grouped bindings by Instance of Source
Dictionary<object,List<Binding>> resolved = new Dictionary<object, List<Binding>>();
}else
targetValue = targetValue.ToString ();
}
- if (targetValue != null)
- b.Target.Property.GetSetMethod ().Invoke
- (b.Target.Instance, new object[] { b.Target.Property.PropertyType.Cast(targetValue)});
- else
- b.Target.Property.GetSetMethod ().Invoke
- (b.Target.Instance, new object[] { targetValue });
+ try {
+ if (targetValue != null)
+ b.Target.Property.GetSetMethod ().Invoke
+ (b.Target.Instance, new object [] { b.Target.Property.PropertyType.Cast (targetValue) });
+ else
+ b.Target.Property.GetSetMethod ().Invoke
+ (b.Target.Instance, new object [] { targetValue });
+ } catch (Exception ex) {
+ Debug.WriteLine (ex.ToString ());
+ }
#endregion
//if no dyn update, skip jump table
il.Emit (OpCodes.Br, endMethod);
i = 0;
- foreach (Binding b in grouped) {
-
+ foreach (Binding b in grouped) {
+
il.MarkLabel (jumpTable [i]);
- il.Emit(OpCodes.Ldloc_1);
+
+
+ //load 2 times to check first for null
+ il.Emit (OpCodes.Ldloc_1);
+ il.Emit (OpCodes.Ldloc_1);
+
+ System.Reflection.Emit.Label labSetValue = il.DefineLabel ();
+ il.Emit (OpCodes.Brtrue, labSetValue);
+ //if null
+ il.Emit (OpCodes.Unbox_Any, b.Target.Property.PropertyType);
+ il.Emit (OpCodes.Callvirt, b.Target.Property.GetSetMethod ());
+ il.Emit (OpCodes.Br, endMethod);
+
+ il.MarkLabel (labSetValue);
+ //new value not null
//by default, source value type is deducted from target member type to allow
//memberless binding, if targetMember exists, it will be used to determine target
throw new Exception ("unhandle target member type in binding");
}
+
+
if (b.Target.Property.PropertyType == typeof(string)) {
MemberReference tostring = new MemberReference (b.Target.Instance);
if (!tostring.FindMember ("ToString"))
il.Emit(OpCodes.Unbox_Any, b.Target.Property.PropertyType);
il.Emit(OpCodes.Callvirt, b.Target.Property.GetSetMethod());
+
+ //il.BeginCatchBlock (typeof (Exception));
+ //il.Emit (OpCodes.Pop);
+ //il.EndExceptionBlock ();
+
il.Emit (OpCodes.Br, endMethod);
i++;