diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2017-01-29 22:13:14 +0100 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2017-01-29 22:13:14 +0100 |
| commit | 2bbceb457f29a1410b99eebbcd42cdb386691b38 (patch) | |
| tree | dfc4556205c31c66fb2b56c2ddf54694c7aa6bc2 /src | |
| parent | 8a25a19ee73e8b7c0c9726bbb2ce4ec918f4e905 (diff) | |
crowObjs type search debug, improve type search in ItemTemplate selection
Diffstat (limited to 'src')
| -rw-r--r-- | src/GraphicObjects/Container.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/Group.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedContainer.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 4 | ||||
| -rw-r--r-- | src/GraphicObjects/TemplatedGroup.cs | 13 | ||||
| -rw-r--r-- | src/Instantiator.cs | 10 | ||||
| -rw-r--r-- | src/ItemTemplate.cs | 13 |
7 files changed, 45 insertions, 7 deletions
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); |