From: jpbruyere Date: Tue, 9 Aug 2016 12:32:23 +0000 (+0200) Subject: Instatiator: use loadTemplate instead of SetChild for adding child in TemplatedControl X-Git-Tag: v0.4~11^2~5 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=19b2404da8c1c8723bb79e58787cd37386d01139;p=jp%2Fcrow.git Instatiator: use loadTemplate instead of SetChild for adding child in TemplatedControl modifié : src/CompilerServices/CompilerServices.cs --- diff --git a/src/CompilerServices/CompilerServices.cs b/src/CompilerServices/CompilerServices.cs index 80b4d535..da15dbf5 100644 --- a/src/CompilerServices/CompilerServices.cs +++ b/src/CompilerServices/CompilerServices.cs @@ -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);