Mercurial > repos > IBBoard.WarFoundry.API
comparison api/Factories/AbstractNonNativeFileExtensionWarFoundryFactory.cs @ 0:520818033bb6
Initial commit of WarFoundry code
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 19 Dec 2008 15:57:51 +0000 |
parents | |
children | 0770e5cbba7c |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:520818033bb6 |
---|---|
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 { | |
36 return IsArmyFile(file) || IsRaceFile(file) || IsSystemFile(file); | |
37 } | |
38 | |
39 protected bool IsArmyFile(FileInfo file) | |
40 { | |
41 return ArmyFileExtension!=null && file.Name.ToLower().EndsWith(ArmyFileExtension); | |
42 } | |
43 | |
44 protected bool IsRaceFile(FileInfo file) | |
45 { | |
46 return RaceFileExtension!=null && file.Name.ToLower().EndsWith(RaceFileExtension); | |
47 } | |
48 | |
49 protected bool IsSystemFile(FileInfo file) | |
50 { | |
51 return GameSystemFileExtension!=null && file.Name.ToLower().EndsWith(GameSystemFileExtension); | |
52 } | |
53 | |
54 protected override FileInfo GetFileAsSupportedType (FileInfo file) | |
55 { | |
56 return file; | |
57 } | |
58 | |
59 | |
60 protected abstract Army CreateArmyFromFile(FileInfo file); | |
61 protected abstract Race CreateRaceFromFile(FileInfo file); | |
62 protected abstract GameSystem CreateGameSystemFromFile(FileInfo file); | |
63 } | |
64 } |