{
public static class CompilerServices
{
+ static MethodInfo miAddBinding = typeof(GraphicObject).GetMethod ("BindMember");
+
public static void BuildInstanciator(IMLInstantiatorBuilder builder, Type crowType){
string tmpXml = builder.ReadOuterXml ();
reader.il.Emit (OpCodes.Callvirt,//add child
typeof(PrivateContainer).GetMethod ("SetChild", BindingFlags.Instance | BindingFlags.NonPublic));
}
+ reader.il.Emit (OpCodes.Ldloc_0);
+ reader.il.Emit (OpCodes.Callvirt, crowType.GetMethod ("ResolveBindings"));
}
}
reader.il.Emit (OpCodes.Ldloc_0);
reader.il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetMethod ("loadDefaultValues"));
+ MethodInfo miAddBinding = typeof(GraphicObject).GetMethod ("BindMember");
+
while (reader.MoveToNextAttribute ()) {
if (reader.Name == "Style")
continue;
- PropertyInfo pi = crowType.GetProperty (reader.Name);
-
+ MemberInfo mi = crowType.GetMember (reader.Name).FirstOrDefault();
+ if (mi == null)
+ throw new Exception ("Member '" + reader.Name + "' not found in " + crowType.Name);
+ if (mi.MemberType == MemberTypes.Event) {
+ emitBindingCreation (reader.il, reader.Name, reader.Value);
+ continue;
+ }
+ PropertyInfo pi = mi as PropertyInfo;
if (pi == null)
throw new Exception ("Member '" + reader.Name + "' not found in " + crowType.Name);
- if (reader.Value.StartsWith("{"))
- Debug.WriteLine("Binding => " + pi.Name + ": " + reader.Value);
- else
+ if (reader.Value.StartsWith ("{")) {
+ emitBindingCreation (reader.il, reader.Name, reader.Value.Substring (1, reader.Value.Length - 2));
+ }else
CompilerServices.EmitSetValue (reader.il, pi, reader.Value);
}
}
builder.il.Emit (OpCodes.Pop);//pop saved ref to current object
}
+ static void emitBindingCreation(ILGenerator il, string memberName, string expression){
+ il.Emit (OpCodes.Ldloc_0);
+ il.Emit (OpCodes.Ldstr, memberName);
+ il.Emit (OpCodes.Ldstr, expression);
+ il.Emit (OpCodes.Callvirt, miAddBinding);
+ }
static void readChildren(IMLInstantiatorBuilder reader, Type crowType){
MethodInfo miAddChild = null;
bool endTagReached = false;
if (Width == Measure.Fit || Height == Measure.Fit)
RegisterForLayouting (LayoutingType.Sizing);
else if (RegisteredLayoutings == LayoutingType.None)
- CurrentInterface.EnqueueForRepaint (this);
+ Interface.CurrentInterface.EnqueueForRepaint (this);
}
/// <summary> query an update of the content, a redraw </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
{
bmp = null;
if (RegisteredLayoutings == LayoutingType.None)
- CurrentInterface.EnqueueForRepaint (this);
- }
- public Interface CurrentInterface {
- get {
- ILayoutable tmp = this.Parent;
- while (tmp != null) {
- if (tmp is Interface)
- return tmp as Interface;
- tmp = tmp.Parent;
- }
- return null;
- }
+ Interface.CurrentInterface.EnqueueForRepaint (this);
}
+// public Interface CurrentInterface {
+// get {
+// ILayoutable tmp = this.Parent;
+// while (tmp != null) {
+// if (tmp is Interface)
+// return tmp as Interface;
+// tmp = tmp.Parent;
+// }
+// return null;
+// }
+// }
#region Layouting