Mercurial > repos > IBBoard.WarFoundry.API
diff api/Factories/Xml/WarFoundryXmlFactory.cs @ 226:c931684f9024
Re #234: Invalid data file doesn't stop load
* Add internal methods to remove game systems or races that fail to load
* Add error handling on XML CompleteLoading so that game system or race is removed, but make sure not to affect error
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 19 Dec 2009 15:40:50 +0000 |
parents | 70ba3bee0c2e |
children | 06b4beb3e156 |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlFactory.cs Thu Dec 17 20:52:22 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs Sat Dec 19 15:40:50 2009 +0000 @@ -118,16 +118,43 @@ public override void CompleteLoading(IWarFoundryStagedLoadObject obj) { - LogNotifier.DebugFormat(GetType(), "Complete loading of {0} with ID {1}", obj.GetType().Name, obj.ID); - - if (obj is GameSystem) - { - gameSystemFactory.CompleteLoading((GameSystem)obj); - } - else if (obj is Race) - { - raceFactory.CompleteLoading((Race)obj); - } + LogNotifier.DebugFormat(GetType(), "Complete loading of {0} with ID {1}", obj.GetType().Name, obj.ID); + + if (obj is GameSystem) + { + CompleteLoadingGameSystem((GameSystem) obj); + } + else if (obj is Race) + { + CompleteLoadingRace((Race) obj); + } + } + + private void CompleteLoadingRace(Race race) + { + try + { + raceFactory.CompleteLoading(race); + } + catch (InvalidFileException ex) + { + WarFoundryLoader.GetDefault().RemoveRace(race); + throw; + } + } + + private void CompleteLoadingGameSystem(GameSystem system) + { + try + { + gameSystemFactory.CompleteLoading(system); + + } + catch (InvalidFileException ex) + { + WarFoundryLoader.GetDefault().RemoveGameSystem(system); + throw; + } } } } \ No newline at end of file