diff api/WarFoundryLoader.cs @ 112:863518044d38

Re #54: Add Army support to WarFoundryFactory * Stop "custom equipment" node being mandatory * Remove unused "ratio" definition * Change "integer or ratio" definition to "integer or percentage" * Use "integer or percentage" definition in army XSD * Add exception to say that required objects were missing (Game System and Race) * Throw exceptions on creating army if game system or race is missing Re #53: Add saving of Army to XML file * Add namespace attributes to XML root node
author IBBoard <dev@ibboard.co.uk>
date Sat, 22 Aug 2009 18:18:20 +0000
parents b5ae022ce7b8
children a143b077a825
line wrap: on
line diff
--- a/api/WarFoundryLoader.cs	Sat Aug 22 15:34:25 2009 +0000
+++ b/api/WarFoundryLoader.cs	Sat Aug 22 18:18:20 2009 +0000
@@ -814,18 +814,21 @@
 		
 		public Army LoadArmy(FileInfo file)
 		{
-			IWarFoundryFactory factory = GetArmyLoadingFactoryForFile(file);
-			ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(file);
-			
+			IWarFoundryFactory factory = GetArmyLoadingFactoryForFile(file);			
 			Army loadedArmy = null;
 			
-			if (objs.Count == 1)
+			if (factory != null)
 			{
-				foreach (IWarFoundryObject obj in objs)
+				ICollection<IWarFoundryObject> objs = factory.CreateObjectsFromFile(file);
+								
+				if (objs.Count == 1)
 				{
-					if (obj is Army)
+					foreach (IWarFoundryObject obj in objs)
 					{
-						loadedArmy = (Army) obj;
+						if (obj is Army)
+						{
+							loadedArmy = (Army) obj;
+						}
 					}
 				}
 			}