comparison api/Factories/AbstractNonNativeFileExtensionWarFoundryFactory.cs @ 14:0770e5cbba7c

Closes #21 - File loading in order * Reworked LoadFiles to smaller methods for readability (also re #10) and structure * Now determine expected load return before loading then load all "expected GameSystem" before "expected Race" * Make "can load as race/game system/army" methods public in interface Re #22 - Get errored file loading * Created FileLoadFailure class and made LoadFiles return a list of them Also * Some code cleanup * Change to DictionaryUtils calls
author IBBoard <dev@ibboard.co.uk>
date Sun, 25 Jan 2009 14:03:20 +0000
parents 520818033bb6
children 306558904c2a
comparison
equal deleted inserted replaced
13:ad8eaed12e66 14:0770e5cbba7c
31 protected abstract string RaceFileExtension { get; } 31 protected abstract string RaceFileExtension { get; }
32 protected abstract string GameSystemFileExtension { get; } 32 protected abstract string GameSystemFileExtension { get; }
33 33
34 protected override bool CheckCanHandleFileFormat (FileInfo file) 34 protected override bool CheckCanHandleFileFormat (FileInfo file)
35 { 35 {
36 return IsArmyFile(file) || IsRaceFile(file) || IsSystemFile(file); 36 return CheckCanHandleFileAsArmy(file) || CheckCanHandleFileAsRace(file) || CheckCanHandleFileAsGameSystem(file);
37 } 37 }
38 38
39 protected bool IsArmyFile(FileInfo file) 39 protected override bool CheckCanHandleFileAsArmy(FileInfo file)
40 { 40 {
41 return ArmyFileExtension!=null && file.Name.ToLower().EndsWith(ArmyFileExtension); 41 return ArmyFileExtension!=null && file.Name.ToLower().EndsWith(ArmyFileExtension);
42 } 42 }
43 43
44 protected bool IsRaceFile(FileInfo file) 44 protected override bool CheckCanHandleFileAsRace(FileInfo file)
45 { 45 {
46 return RaceFileExtension!=null && file.Name.ToLower().EndsWith(RaceFileExtension); 46 return RaceFileExtension!=null && file.Name.ToLower().EndsWith(RaceFileExtension);
47 } 47 }
48 48
49 protected bool IsSystemFile(FileInfo file) 49 protected override bool CheckCanHandleFileAsGameSystem(FileInfo file)
50 { 50 {
51 return GameSystemFileExtension!=null && file.Name.ToLower().EndsWith(GameSystemFileExtension); 51 return GameSystemFileExtension!=null && file.Name.ToLower().EndsWith(GameSystemFileExtension);
52 } 52 }
53 53
54 protected override FileInfo GetFileAsSupportedType (FileInfo file) 54 protected override FileInfo GetFileAsSupportedType (FileInfo file)
55 { 55 {
56 return file; 56 return file;
57 } 57 }
58
59 58
60 protected abstract Army CreateArmyFromFile(FileInfo file); 59 protected abstract Army CreateArmyFromFile(FileInfo file);
61 protected abstract Race CreateRaceFromFile(FileInfo file); 60 protected abstract Race CreateRaceFromFile(FileInfo file);
62 protected abstract GameSystem CreateGameSystemFromFile(FileInfo file); 61 protected abstract GameSystem CreateGameSystemFromFile(FileInfo file);
63 } 62 }