diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-01-30 00:28:05 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2018-01-30 00:28:05 +0100 |
| commit | c29275576f75534c9fd109b3d3717ab52ec8415b (patch) | |
| tree | 2bb12851411af33988a43ea9a35bfe4ee34eba83 /src/Instantiator.cs | |
| parent | e3c509d4a9a27f663a3a95ab697bfdb2e880172d (diff) | |
- test with both parameterless ctor and with iface param ctorInCodeInstatiation
- CurrentInterface as field
Diffstat (limited to 'src/Instantiator.cs')
| -rw-r--r-- | src/Instantiator.cs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Instantiator.cs b/src/Instantiator.cs index 3520ce83..42c5de96 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -161,6 +161,12 @@ namespace Crow //emitCheckAndBindValueChanged (ctx); } + /// <summary> + /// process template and item template definition prior to + /// other attributes or childs processing + /// </summary> + /// <param name="ctx">Loading Context</param> + /// <param name="tmpXml">xml fragment</param> void emitTemplateLoad (Context ctx, string tmpXml) { //if its a template, first read template elements using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) { @@ -242,11 +248,17 @@ namespace Crow } } } + /// <summary> + /// process styling, attributes and children loading. + /// </summary> + /// <param name="ctx">parsing context</param> + /// <param name="tmpXml">xml fragment</param> void emitGOLoad (Context ctx, string tmpXml) { using (XmlTextReader reader = new XmlTextReader (tmpXml, XmlNodeType.Element, null)) { reader.Read (); #region Styling and default values loading + //first check for Style attribute then trigger default value loading if (reader.HasAttributes) { string style = reader.GetAttribute ("Style"); if (!string.IsNullOrEmpty (style)) @@ -328,8 +340,12 @@ namespace Crow Type t = tryGetGOType (reader.Name); if (t == null) throw new Exception (reader.Name + " type not found"); - - ctx.il.Emit (OpCodes.Newobj, t.GetConstructors () [0]);//TODO:search parameterless ctor + ConstructorInfo ci = t.GetConstructor ( + BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, + null, Type.EmptyTypes, null); + if (ci == null) + throw new Exception ("No default parameterless constructor found in " + t.Name); + ctx.il.Emit (OpCodes.Newobj, ci); ctx.il.Emit (OpCodes.Stloc_0);//child is now loc_0 CompilerServices.emitSetCurInterface (ctx.il); |