]> O.S.I.I.S - jp/crow.git/commitdiff
crowObjs type search debug, improve type search in ItemTemplate selection
authorjpbruyere <jp.bruyere@hotmail.com>
Sun, 29 Jan 2017 21:13:14 +0000 (22:13 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Sun, 29 Jan 2017 21:13:14 +0000 (22:13 +0100)
src/GraphicObjects/Container.cs
src/GraphicObjects/Group.cs
src/GraphicObjects/TemplatedContainer.cs
src/GraphicObjects/TemplatedControl.cs
src/GraphicObjects/TemplatedGroup.cs
src/Instantiator.cs
src/ItemTemplate.cs

index 0b6045bb0a690c77e9b8d209b40c5ddbe79c2ee1..be6774b56b8aae0210089d7b2c3e1428bd8f38c8 100644 (file)
@@ -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);
index a285e28214222bdaf5d73a796f6d025413159c33..3c5091855de872fa07226c53c0921eb501fce1c3 100644 (file)
@@ -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)
index 44c2ad08931294194a42963a08f2d935ba60986c..f4243588ac2565d5a562eda13b1febaf54074614 100644 (file)
@@ -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)
index ba49f44fd0d854f7017527ee089464641b797562..4a3a2507b92ca0286685109c1450524a3ec5b8ac 100644 (file)
@@ -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);
index a1941f06b10c84cb351f98fe0a1fad04b78ce7f3..4c35197f2fc40e4f80d7f6da9a7060ae06b021b3 100644 (file)
@@ -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
index 6e94ae171f4582383c0721213c24b47b4a66a9d1..e738a74175c05d825701e76a5bb26f000cce29e3 100644 (file)
@@ -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)
index 1f03f7f8af9523f8156eb9871d8b25ee96f4cd50..34085d2bc42be7bc837444c76fba8041ebe84dff 100644 (file)
@@ -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);