aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/IMLReader.cs
diff options
context:
space:
mode:
authorjpbruyere <jp.bruyere@hotmail.com>2016-08-18 17:26:50 +0200
committerjpbruyere <jp.bruyere@hotmail.com>2016-09-01 12:44:38 +0200
commit5fc76c5f6234fcdcf208607c434a6d5d8bbf79da (patch)
tree393b14c6c193846d33e7e5842d34250333a4cfaa /src/IMLReader.cs
parentd4bc4a1aba5df1d5a93474259c5d5a52f993d475 (diff)
tests reorganization
modifié : Crow.csproj modifié : Tests/BasicTests.cs renommé : Tests/Interfaces/Expandable/0.crow -> Tests/Interfaces/TemplatedContainer/0.crow renommé : Tests/Interfaces/Expandable/6.crow -> Tests/Interfaces/TemplatedContainer/6.crow renommé : Tests/Interfaces/Expandable/7.crow -> Tests/Interfaces/TemplatedContainer/7.crow renommé : Tests/Interfaces/Divers/testDirViewer2.crow -> Tests/Interfaces/TemplatedContainer/testDirViewer2.crow renommé : Tests/Interfaces/Divers/testGroupBox.crow -> Tests/Interfaces/TemplatedContainer/testGroupBox.crow renommé : Tests/Interfaces/Divers/testMsgBox.crow -> Tests/Interfaces/TemplatedContainer/testMsgBox.crow renommé : Tests/Interfaces/Divers/testPopper.crow -> Tests/Interfaces/TemplatedContainer/testPopper.crow renommé : Tests/Interfaces/Divers/testTabView.crow -> Tests/Interfaces/TemplatedContainer/testTabView.crow renommé : Tests/Interfaces/Divers/testTreeView.crow -> Tests/Interfaces/TemplatedContainer/testTreeView.crow renommé : Tests/Interfaces/Divers/testWindow.goml -> Tests/Interfaces/TemplatedContainer/testWindow.goml renommé : Tests/Interfaces/Divers/testWindow2.goml -> Tests/Interfaces/TemplatedContainer/testWindow2.goml renommé : Tests/Interfaces/Divers/testWindow3.goml -> Tests/Interfaces/TemplatedContainer/testWindow3.goml renommé : Tests/Interfaces/Divers/test_Listbox.crow -> Tests/Interfaces/TemplatedContainer/test_Listbox.crow renommé : Tests/Interfaces/Divers/testButton.crow -> Tests/Interfaces/TemplatedControl/testButton.crow renommé : Tests/Interfaces/Divers/testCheckbox.crow -> Tests/Interfaces/TemplatedControl/testCheckbox.crow renommé : Tests/Interfaces/Divers/testCombobox.crow -> Tests/Interfaces/TemplatedControl/testCombobox.crow renommé : Tests/Interfaces/Divers/testItemTemplateTag.crow -> Tests/Interfaces/TemplatedControl/testItemTemplateTag.crow renommé : Tests/Interfaces/Divers/testRadioButton.crow -> Tests/Interfaces/TemplatedControl/testRadioButton.crow renommé : Tests/Interfaces/Divers/testScrollbar.goml -> Tests/Interfaces/TemplatedControl/testScrollbar.goml renommé : Tests/Interfaces/Divers/testSpinner.goml -> Tests/Interfaces/TemplatedControl/testSpinner.goml modifié : Tests/Tests.csproj modifié : src/GraphicObjects/Expandable.cs modifié : src/GraphicObjects/Group.cs TemplatedGroup class nouveau fichier : src/GraphicObjects/TemplatedGroup.cs nouveau fichier : Tests/Interfaces/TemplatedGroup/0.crow modifié : src/IMLReader.cs
Diffstat (limited to 'src/IMLReader.cs')
-rw-r--r--src/IMLReader.cs24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/IMLReader.cs b/src/IMLReader.cs
index e4f98ecb..922a48d7 100644
--- a/src/IMLReader.cs
+++ b/src/IMLReader.cs
@@ -107,6 +107,7 @@ namespace Crow
il.Emit (OpCodes.Ldloc_0);//save current go onto the stack if child has to be added
+ #region Template and TemplateItems loading
if (typeof(TemplatedControl).IsAssignableFrom (crowType)) {
//if its a template, first read template elements
using (IMLReader reader = new IMLReader (il, tmpXml)) {
@@ -188,10 +189,12 @@ namespace Crow
}
}
}
+ #endregion
using (IMLReader reader = new IMLReader(il,tmpXml)){
reader.Read ();
+ #region Styling and default values loading
if (reader.HasAttributes) {
string style = reader.GetAttribute ("Style");
if (!string.IsNullOrEmpty (style)) {
@@ -201,7 +204,9 @@ namespace Crow
}
reader.il.Emit (OpCodes.Ldloc_0);
reader.il.Emit (OpCodes.Callvirt, typeof(GraphicObject).GetMethod ("loadDefaultValues"));
+ #endregion
+ #region Attributes reading
if (reader.HasAttributes) {
MethodInfo miAddBinding = typeof(GraphicObject).GetMethod ("BindMember");
@@ -229,6 +234,7 @@ namespace Crow
}
reader.MoveToElement ();
}
+ #endregion
if (reader.IsEmptyElement) {
reader.il.Emit (OpCodes.Pop);//pop saved ref to current object
@@ -253,7 +259,7 @@ namespace Crow
case XmlNodeType.Element:
//Templates
if (reader.Name == "Template" ||
- reader.Name == "ItemTemplate") {
+ reader.Name == "ItemTemplate") {
reader.Skip ();
continue;
}
@@ -263,16 +269,18 @@ namespace Crow
miAddChild = typeof(Group).GetMethod ("AddChild");
else if (typeof(Container).IsAssignableFrom (crowType))
miAddChild = typeof(Container).GetMethod ("SetChild");
- else if (typeof(TemplatedContainer).IsAssignableFrom (crowType)&&!templateLoading)
- miAddChild = typeof(TemplatedContainer).GetProperty("Content").GetSetMethod();
+ else if (typeof(TemplatedContainer).IsAssignableFrom (crowType) && !templateLoading)
+ miAddChild = typeof(TemplatedContainer).GetProperty ("Content").GetSetMethod ();
+ else if (typeof(TemplatedGroup).IsAssignableFrom (crowType) && !templateLoading)
+ miAddChild = typeof(TemplatedGroup).GetMethod ("AddItem",
+ BindingFlags.Instance | BindingFlags.Public);
else if (typeof(TemplatedControl).IsAssignableFrom (crowType))
miAddChild = typeof(TemplatedControl).GetMethod ("loadTemplate",
- BindingFlags.Instance | BindingFlags.NonPublic);
+ BindingFlags.Instance | BindingFlags.NonPublic);
else if (typeof(PrivateContainer).IsAssignableFrom (crowType))
miAddChild = typeof(PrivateContainer).GetMethod ("SetChild",
BindingFlags.Instance | BindingFlags.NonPublic);
}
-
//push current instance on stack for parenting
//loc_0 will be used for child
reader.il.Emit (OpCodes.Ldloc_0);
@@ -288,13 +296,15 @@ namespace Crow
if (t == null)
throw new Exception (reader.Name + " type not found");
- reader.il.Emit(OpCodes.Newobj, t.GetConstructors () [0]);//TODO:search parameterless ctor
+ reader.il.Emit (OpCodes.Newobj, t.GetConstructors () [0]);//TODO:search parameterless ctor
reader.il.Emit (OpCodes.Stloc_0);//child is now loc_0
CompilerServices.emitSetCurInterface (il);
- reader.emitLoader(t);
+ reader.emitLoader (t);
reader.il.Emit (OpCodes.Ldloc_0);//load child on stack for parenting
+ if (miAddChild == null)
+ System.Diagnostics.Debugger.Break ();
reader.il.Emit (OpCodes.Callvirt, miAddChild);
reader.il.Emit (OpCodes.Stloc_0); //reset local to current go
reader.il.Emit (OpCodes.Ldloc_0);//save current go onto the stack if child has to be added