From: jpbruyere Date: Sun, 29 Jan 2017 21:13:14 +0000 (+0100) Subject: crowObjs type search debug, improve type search in ItemTemplate selection X-Git-Tag: v0.9.5-beta~259^2~1 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=2bbceb457f29a1410b99eebbcd42cdb386691b38;p=jp%2Fcrow.git crowObjs type search debug, improve type search in ItemTemplate selection --- diff --git a/src/GraphicObjects/Container.cs b/src/GraphicObjects/Container.cs index 0b6045bb..be6774b5 100644 --- a/src/GraphicObjects/Container.cs +++ b/src/GraphicObjects/Container.cs @@ -50,8 +50,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == subTree.Name) + if (expT.Name == subTree.Name) { t = expT; + break; + } } } GraphicObject go = (GraphicObject)Activator.CreateInstance(t); diff --git a/src/GraphicObjects/Group.cs b/src/GraphicObjects/Group.cs index a285e282..3c509185 100644 --- a/src/GraphicObjects/Group.cs +++ b/src/GraphicObjects/Group.cs @@ -337,8 +337,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == subTree.Name) + if (expT.Name == subTree.Name) { t = expT; + break; + } } } if (t == null) diff --git a/src/GraphicObjects/TemplatedContainer.cs b/src/GraphicObjects/TemplatedContainer.cs index 44c2ad08..f4243588 100644 --- a/src/GraphicObjects/TemplatedContainer.cs +++ b/src/GraphicObjects/TemplatedContainer.cs @@ -84,8 +84,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == xr.Name) + if (expT.Name == xr.Name) { t = expT; + break; + } } } if (t == null) diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index ba49f44f..4a3a2507 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -154,8 +154,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == xr.Name) + if (expT.Name == xr.Name) { t = expT; + break; + } } } GraphicObject go = (GraphicObject)Activator.CreateInstance (t); diff --git a/src/GraphicObjects/TemplatedGroup.cs b/src/GraphicObjects/TemplatedGroup.cs index a1941f06..4c35197f 100644 --- a/src/GraphicObjects/TemplatedGroup.cs +++ b/src/GraphicObjects/TemplatedGroup.cs @@ -272,8 +272,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == xr.Name) + if (expT.Name == xr.Name) { t = expT; + break; + } } } if (t == null) @@ -385,6 +387,15 @@ namespace Crow else { foreach (string it in ItemTemplates.Keys) { Type t = Type.GetType (it); + if (t == null) { + Assembly a = Assembly.GetEntryAssembly (); + foreach (Type expT in a.GetExportedTypes ()) { + if (expT.Name == it) { + t = expT; + break; + } + } + } if (t == null) continue; if (t.IsAssignableFrom (dataType)) {//TODO:types could be cached diff --git a/src/Instantiator.cs b/src/Instantiator.cs index 6e94ae17..e738a741 100644 --- a/src/Instantiator.cs +++ b/src/Instantiator.cs @@ -139,10 +139,14 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == root) + if (expT.Name == root) { t = expT; + break; + } } } + if (t == null) + throw new Exception ("IML parsing error: undefined root type (" + root + ")"); return t; } void emitLoader (XmlTextReader reader, Context ctx) @@ -324,8 +328,10 @@ namespace Crow if (t == null) { Assembly a = Assembly.GetEntryAssembly (); foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == reader.Name) + if (expT.Name == reader.Name) { t = expT; + break; + } } } if (t == null) diff --git a/src/ItemTemplate.cs b/src/ItemTemplate.cs index 1f03f7f8..34085d2b 100644 --- a/src/ItemTemplate.cs +++ b/src/ItemTemplate.cs @@ -56,6 +56,19 @@ namespace Crow public void CreateExpandDelegate (TemplatedGroup host){ Type dataType = Type.GetType(strDataType); + if (dataType == null) { + Assembly a = Assembly.GetEntryAssembly (); + foreach (Type expT in a.GetExportedTypes ()) { + if (expT.Name == strDataType) { + dataType = expT; + break; + } + } + } + if (dataType == null) { + Debug.WriteLine ("ItemTemplate error: DataType not found: {0}.", strDataType); + return; + } Type tmpGrpType = typeof(TemplatedGroup); Type evtType = typeof(EventHandler);