Mercurial > repos > IBBoard.WarFoundry.API
comparison 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 |
comparison
equal
deleted
inserted
replaced
225:0d5a17f33a36 | 226:c931684f9024 |
---|---|
117 } | 117 } |
118 | 118 |
119 public override void CompleteLoading(IWarFoundryStagedLoadObject obj) | 119 public override void CompleteLoading(IWarFoundryStagedLoadObject obj) |
120 { | 120 { |
121 LogNotifier.DebugFormat(GetType(), "Complete loading of {0} with ID {1}", obj.GetType().Name, obj.ID); | 121 LogNotifier.DebugFormat(GetType(), "Complete loading of {0} with ID {1}", obj.GetType().Name, obj.ID); |
122 | 122 |
123 if (obj is GameSystem) | 123 if (obj is GameSystem) |
124 { | |
125 CompleteLoadingGameSystem((GameSystem) obj); | |
126 } | |
127 else if (obj is Race) | |
128 { | |
129 CompleteLoadingRace((Race) obj); | |
130 } | |
131 } | |
132 | |
133 private void CompleteLoadingRace(Race race) | |
134 { | |
135 try | |
124 { | 136 { |
125 gameSystemFactory.CompleteLoading((GameSystem)obj); | 137 raceFactory.CompleteLoading(race); |
126 } | 138 } |
127 else if (obj is Race) | 139 catch (InvalidFileException ex) |
128 { | 140 { |
129 raceFactory.CompleteLoading((Race)obj); | 141 WarFoundryLoader.GetDefault().RemoveRace(race); |
142 throw; | |
130 } | 143 } |
144 } | |
145 | |
146 private void CompleteLoadingGameSystem(GameSystem system) | |
147 { | |
148 try | |
149 { | |
150 gameSystemFactory.CompleteLoading(system); | |
151 | |
152 } | |
153 catch (InvalidFileException ex) | |
154 { | |
155 WarFoundryLoader.GetDefault().RemoveGameSystem(system); | |
156 throw; | |
157 } | |
131 } | 158 } |
132 } | 159 } |
133 } | 160 } |