annotate api/Factories/AbstractNonNativeFileExtensionWarFoundryFactory.cs @ 18:3c228f093a71

Re #16 - Complete Rollcall file loading * Add default implementation to "do create" method in non-native factory Also commit csproj changes and removal of old mdp file
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Feb 2009 14:23:53 +0000
parents 306558904c2a
children b7c93a5821cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
1 // This file (AbstractNonNativeFileExtensionWarFoundryFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard.
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
15
306558904c2a Re #1 - LGPL license all code
IBBoard <dev@ibboard.co.uk>
parents: 14
diff changeset
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.Collections.Generic;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.IO;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Objects;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 namespace IBBoard.WarFoundry.API.Factories
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public abstract class AbstractNonNativeFileExtensionWarFoundryFactory : AbstractNonNativeWarFoundryFactory<FileInfo>
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 protected abstract string ArmyFileExtension { get; }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 protected abstract string RaceFileExtension { get; }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 protected abstract string GameSystemFileExtension { get; }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 protected override bool CheckCanHandleFileFormat (FileInfo file)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
20 return CheckCanHandleFileAsArmy(file) || CheckCanHandleFileAsRace(file) || CheckCanHandleFileAsGameSystem(file);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
23 protected override bool CheckCanHandleFileAsArmy(FileInfo file)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 return ArmyFileExtension!=null && file.Name.ToLower().EndsWith(ArmyFileExtension);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
28 protected override bool CheckCanHandleFileAsRace(FileInfo file)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 return RaceFileExtension!=null && file.Name.ToLower().EndsWith(RaceFileExtension);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
33 protected override bool CheckCanHandleFileAsGameSystem(FileInfo file)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 return GameSystemFileExtension!=null && file.Name.ToLower().EndsWith(GameSystemFileExtension);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 protected override FileInfo GetFileAsSupportedType (FileInfo file)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 return file;
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
41 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 protected abstract Army CreateArmyFromFile(FileInfo file);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 protected abstract Race CreateRaceFromFile(FileInfo file);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 protected abstract GameSystem CreateGameSystemFromFile(FileInfo file);
18
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
46
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
47 protected override ICollection<IWarFoundryObject> DoCreateObjectsFromFile (FileInfo file)
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
48 {
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
49 ICollection<IWarFoundryObject> objects = new List<IWarFoundryObject>();
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
50
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
51 if (CheckCanHandleFileAsRace(file))
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
52 {
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
53 objects.Add(CreateRaceFromFile(file));
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
54 }
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
55 else if (CheckCanHandleFileAsGameSystem(file))
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
56 {
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
57 objects.Add(CreateGameSystemFromFile(file));
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
58 }
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
59 else if (CheckCanHandleFileAsArmy(file))
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
60 {
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
61 objects.Add(CreateArmyFromFile(file));
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
62 }
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
63
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
64 return objects;
3c228f093a71 Re #16 - Complete Rollcall file loading
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
65 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 }