Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate 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 |
rev | line source |
---|---|
0 | 1 // AbstractNonNativeFileExtensionWarFoundryFactory.cs |
2 // | |
3 // Copyright (C) 2008 IBBoard | |
4 // | |
5 // This library is free software; you can redistribute it and/or | |
6 // modify it under the terms of the GNU Lesser General Public | |
7 // License as published by the Free Software Foundation; either | |
8 // version 2.1 of the License, or (at your option) any later version. | |
9 // | |
10 // This library is distributed in the hope that it will be useful, | |
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 // Lesser General Public License for more details. | |
14 // | |
15 // You should have received a copy of the GNU Lesser General Public | |
16 // License along with this library; if not, write to the Free Software | |
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 // | |
19 // | |
20 | |
21 using System; | |
22 using System.Collections.Generic; | |
23 using System.IO; | |
24 using IBBoard.WarFoundry.API.Objects; | |
25 | |
26 namespace IBBoard.WarFoundry.API.Factories | |
27 { | |
28 public abstract class AbstractNonNativeFileExtensionWarFoundryFactory : AbstractNonNativeWarFoundryFactory<FileInfo> | |
29 { | |
30 protected abstract string ArmyFileExtension { get; } | |
31 protected abstract string RaceFileExtension { get; } | |
32 protected abstract string GameSystemFileExtension { get; } | |
33 | |
34 protected override bool CheckCanHandleFileFormat (FileInfo file) | |
35 { | |
14
0770e5cbba7c
Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
36 return CheckCanHandleFileAsArmy(file) || CheckCanHandleFileAsRace(file) || CheckCanHandleFileAsGameSystem(file); |
0 | 37 } |
38 | |
14
0770e5cbba7c
Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
39 protected override bool CheckCanHandleFileAsArmy(FileInfo file) |
0 | 40 { |
41 return ArmyFileExtension!=null && file.Name.ToLower().EndsWith(ArmyFileExtension); | |
42 } | |
43 | |
14
0770e5cbba7c
Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
44 protected override bool CheckCanHandleFileAsRace(FileInfo file) |
0 | 45 { |
46 return RaceFileExtension!=null && file.Name.ToLower().EndsWith(RaceFileExtension); | |
47 } | |
48 | |
14
0770e5cbba7c
Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
49 protected override bool CheckCanHandleFileAsGameSystem(FileInfo file) |
0 | 50 { |
51 return GameSystemFileExtension!=null && file.Name.ToLower().EndsWith(GameSystemFileExtension); | |
52 } | |
53 | |
54 protected override FileInfo GetFileAsSupportedType (FileInfo file) | |
55 { | |
56 return file; | |
14
0770e5cbba7c
Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents:
0
diff
changeset
|
57 } |
0 | 58 |
59 protected abstract Army CreateArmyFromFile(FileInfo file); | |
60 protected abstract Race CreateRaceFromFile(FileInfo file); | |
61 protected abstract GameSystem CreateGameSystemFromFile(FileInfo file); | |
62 } | |
63 } |