]> O.S.I.I.S - jp/crow.git/commitdiff
Instatiator: use loadTemplate instead of SetChild for adding child in TemplatedControl
authorjpbruyere <jp.bruyere@hotmail.com>
Tue, 9 Aug 2016 12:32:23 +0000 (14:32 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Tue, 9 Aug 2016 12:32:23 +0000 (14:32 +0200)
modifié :         src/CompilerServices/CompilerServices.cs

src/CompilerServices/CompilerServices.cs

index 80b4d5351f043a2ab095a18b449fd9055d22c5b4..da15dbf5dd15bb24b3d011a5423974d3b60cb015 100644 (file)
@@ -51,11 +51,9 @@ namespace Crow
                                                reader.il.Emit (OpCodes.Ldstr, template); //Load template path string
                                                reader.il.Emit (OpCodes.Callvirt,//call Interface.Load(path)
                                                        typeof(Interface).GetMethod ("Load", BindingFlags.Static | BindingFlags.Public));
-                                               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.Callvirt,//add child
+                                               typeof(TemplatedControl).GetMethod ("loadTemplate", BindingFlags.Instance | BindingFlags.NonPublic));
                                }
                        }
 
@@ -124,6 +122,11 @@ namespace Crow
                                        break;
                                case XmlNodeType.Element:
                                        //Templates
+                                       if (reader.Name == "Template" ||
+                                           reader.Name == "ItemTemplate") {
+                                               reader.Skip ();
+                                               continue;
+                                       }
 
 
                                        if (miAddChild == null) {
@@ -131,6 +134,8 @@ namespace Crow
                                                        miAddChild = typeof(Group).GetMethod ("AddChild");
                                                else if (typeof(Container).IsAssignableFrom (crowType))
                                                        miAddChild = typeof(Container).GetMethod ("SetChild");
+                                               else if (typeof(TemplatedContainer).IsAssignableFrom (crowType))
+                                                       miAddChild = typeof(TemplatedContainer).GetProperty("Content").GetSetMethod();
                                                else if (typeof(PrivateContainer).IsAssignableFrom (crowType))
                                                        miAddChild = typeof(PrivateContainer).GetMethod ("SetChild",
                                                                BindingFlags.Instance | BindingFlags.NonPublic);