Mercurial > repos > IBBoard.WarFoundry.API
comparison api/WarFoundryLoader.cs @ 144:721891008b5c
Fixes #22: Add functionality to get failed file loads and reason
* Add event for file load start and end - end event has list of failures as parameter
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 21 Sep 2009 18:58:50 +0000 |
parents | 32b774f24017 |
children | c931684f9024 |
comparison
equal
deleted
inserted
replaced
143:7f13ffcb8765 | 144:721891008b5c |
---|---|
38 private ICollection<INativeWarFoundryFactory> factories; | 38 private ICollection<INativeWarFoundryFactory> factories; |
39 private ICollection<INonNativeWarFoundryFactory> nonNativeFactories; | 39 private ICollection<INonNativeWarFoundryFactory> nonNativeFactories; |
40 private Dictionary<string, GameSystem> systemsTable; | 40 private Dictionary<string, GameSystem> systemsTable; |
41 private Dictionary<string, Dictionary<string, Dictionary<string, Race>>> racesTable; //Keys are: System, Race, SubRace | 41 private Dictionary<string, Dictionary<string, Dictionary<string, Race>>> racesTable; //Keys are: System, Race, SubRace |
42 private Dictionary<IWarFoundryFactory, SimpleSet<IWarFoundryObject>> loadedObjects; | 42 private Dictionary<IWarFoundryFactory, SimpleSet<IWarFoundryObject>> loadedObjects; |
43 | 43 public delegate void FileLoadingCompleteDelegate(List<FileLoadFailure> failures); |
44 protected WarFoundryLoader() | 44 public event MethodInvoker FileLoadingStarted; |
45 public event FileLoadingCompleteDelegate FileLoadingFinished; | |
46 | |
47 private WarFoundryLoader() | |
45 { | 48 { |
46 directories = new List<DirectoryInfo>(); | 49 directories = new List<DirectoryInfo>(); |
47 factories = new List<INativeWarFoundryFactory>(); | 50 factories = new List<INativeWarFoundryFactory>(); |
48 nonNativeFactories = new List<INonNativeWarFoundryFactory>(); | 51 nonNativeFactories = new List<INonNativeWarFoundryFactory>(); |
49 loadedObjects = new Dictionary<IWarFoundryFactory,SimpleSet<IWarFoundryObject>>(); | 52 loadedObjects = new Dictionary<IWarFoundryFactory,SimpleSet<IWarFoundryObject>>(); |
146 Dictionary<FileInfo, IWarFoundryFactory> loadableRaces = new Dictionary<FileInfo, IWarFoundryFactory>(); | 149 Dictionary<FileInfo, IWarFoundryFactory> loadableRaces = new Dictionary<FileInfo, IWarFoundryFactory>(); |
147 Dictionary<FileInfo, IWarFoundryFactory> loadableGameSystems = new Dictionary<FileInfo, IWarFoundryFactory>(); | 150 Dictionary<FileInfo, IWarFoundryFactory> loadableGameSystems = new Dictionary<FileInfo, IWarFoundryFactory>(); |
148 List<FileLoadFailure> failedLoads = FillLoadableFiles(loadableRaces, loadableGameSystems); | 151 List<FileLoadFailure> failedLoads = FillLoadableFiles(loadableRaces, loadableGameSystems); |
149 failedLoads.AddRange(LoadGameSystems(loadableGameSystems)); | 152 failedLoads.AddRange(LoadGameSystems(loadableGameSystems)); |
150 failedLoads.AddRange(LoadRaces(loadableRaces)); | 153 failedLoads.AddRange(LoadRaces(loadableRaces)); |
151 | 154 OnFileLoadingFinished(failedLoads); |
152 LogNotifier.Debug(GetType(), failedLoads.Count + " failed file loads"); | |
153 | |
154 return failedLoads; | 155 return failedLoads; |
156 } | |
157 | |
158 private void OnFileLoadingFinished(List<FileLoadFailure> failures) | |
159 { | |
160 if (FileLoadingFinished!=null) | |
161 { | |
162 FileLoadingFinished(failures); | |
163 } | |
155 } | 164 } |
156 | 165 |
157 protected void PrepareForFileLoad() | 166 protected void PrepareForFileLoad() |
158 { | 167 { |
159 //Just set up blank dictionaries for now - may try different and more complex handling in future | 168 //Just set up blank dictionaries for now - may try different and more complex handling in future |