annotate API/Factories/AbstractWarFoundryFactory.cs @ 443:86725e88052e

Re #380: WarFoundry chokes on zips written by Mac OS X * Add "is dot-file" check to behave like Linux and Mac and ignore files with name ".something" Also: * Fix load failure message argument order * Save some regex checks by making sure zip entry is a file first
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Dec 2011 20:40:31 +0000
parents 3c4a6403a88c
children 1ed2f3ab5e35
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
337
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (AbstractWarFoundryFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using System;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using System.IO;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.Collections.Generic;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Objects;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 namespace IBBoard.WarFoundry.API.Factories
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public abstract class AbstractWarFoundryFactory<FILE_TYPE> : IWarFoundryFactory
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public event SingleArgMethodInvoker<GameSystem> GameSystemLoaded;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public event SingleArgMethodInvoker<Race> RaceLoaded;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 public event SingleArgMethodInvoker<Army> ArmyLoaded;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 public virtual void CompleteLoading(IWarFoundryStagedLoadObject obj)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 //Pretend we've fully loaded, as this will probably be standard for non-native factories and some native factories
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 obj.SetAsFullyLoaded();
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 public bool CanHandleFileFormat (FileInfo file)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 FILE_TYPE typedFile = GetFileAsSupportedType(file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 bool canHandle = typedFile != null && CheckCanHandleFileFormat(typedFile);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 if (typedFile != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 CleanUpFileAsSupportedType(typedFile);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 return canHandle;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 public bool CanHandleFileAsRace(FileInfo file)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 FILE_TYPE typedFile = GetFileAsSupportedType(file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 bool canHandle = typedFile != null && CheckCanHandleFileAsRace(typedFile);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 if (typedFile != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 CleanUpFileAsSupportedType(typedFile);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 return canHandle;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 public bool CanHandleFileAsGameSystem(FileInfo file)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 FILE_TYPE typedFile = GetFileAsSupportedType(file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 bool canHandle = typedFile != null && CheckCanHandleFileAsGameSystem(typedFile);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 if (typedFile != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 CleanUpFileAsSupportedType(typedFile);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62 return canHandle;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
63 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
65 public bool CanHandleFileAsArmy(FileInfo file)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
66 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
67 FILE_TYPE typedFile = GetFileAsSupportedType(file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 bool canHandle = typedFile != null && CheckCanHandleFileAsArmy(typedFile);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
70 if (typedFile != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
72 CleanUpFileAsSupportedType(typedFile);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 return canHandle;
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 protected virtual void CleanUpFileAsSupportedType(FILE_TYPE typedFile)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
80 //Do nothing by default
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
81 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
82
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
83 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
84 /// Converts the <see cref="FileInfo"/> object in to the appropriate type for this class so that it can perform its checks. If no conversion is required (the test can be performed on a <see cref="FileInfo"/> object) the object should be returned with no modification.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
85 /// If the file is not of supported type the <code>null</code> should be returned.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
86 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
87 /// <param name="file">
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
88 /// A <see cref="FileInfo"/> to get the supported source object from.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
89 /// </param>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
90 /// <returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
91 /// An object of type <see cref="FILE_TYPE"/> that has been converted from the input <see cref="FileInfo"/> object, or <code>null</code> if the conversion cannot be made.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
92 /// </returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
93 protected abstract FILE_TYPE GetFileAsSupportedType(FileInfo file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
94
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
95 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
96 /// Checks whether the factory thinks it can load data from the file in its paramaterised type.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
97 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
98 /// <param name="file">
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
99 /// An object of the converted <see cref="FILE_TYPE"/> to check support for
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 /// </param>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101 /// <returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 /// <code>true</code> if the factory thinks it can support the file, else <code>false</code>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 /// </returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 protected abstract bool CheckCanHandleFileFormat(FILE_TYPE file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
106 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107 /// Checks whether the factory thinks it can load data from the file in its paramaterised type as a Race object.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 /// <param name="file">
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110 /// An object of the converted <see cref="FILE_TYPE"/> to check support for
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 /// </param>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 /// <returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
113 /// <code>true</code> if the factory thinks it can support the file as a Race, else <code>false</code>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
114 /// </returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
115 protected abstract bool CheckCanHandleFileAsRace(FILE_TYPE file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
116
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
117 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
118 /// Checks whether the factory thinks it can load data from the file in its paramaterised type as a GameSystem object.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
119 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
120 /// <param name="file">
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
121 /// An object of the converted <see cref="FILE_TYPE"/> to check support for
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
122 /// </param>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 /// <returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124 /// <code>true</code> if the factory thinks it can support the file as a GameSystem, else <code>false</code>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 /// </returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 protected abstract bool CheckCanHandleFileAsGameSystem(FILE_TYPE file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
129 /// Checks whether the factory thinks it can load data from the file in its paramaterised type as an Army object.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
130 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
131 /// <param name="file">
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132 /// An object of the converted <see cref="FILE_TYPE"/> to check support for
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 /// </param>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
134 /// <returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 /// <code>true</code> if the factory thinks it can support the file as a Army, else <code>false</code>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
136 /// </returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
137 protected abstract bool CheckCanHandleFileAsArmy(FILE_TYPE file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
138
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 public ICollection<IWarFoundryObject> CreateObjectsFromFile(FileInfo file)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 return DoCreateObjectsFromFile(GetFileAsSupportedType(file));
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 /// <summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
146 /// Reads the data from the supplied converted <see cref="FILE_TYPE"/> object and returns it as a collection of loadable objects.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
147 /// In addition, the method fires the appropriate XxxLoaded event for each object created for asynchronous use.
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
148 /// </summary>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
149 /// <param name="file">
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
150 /// An object of the converted <see cref="FILE_TYPE"/> for the file to load data from
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
151 /// </param>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
152 /// <returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
153 /// A <see cref="ICollection`1"/> of <see cref="IWarFoundryObject"/>s that were loaded from the file object
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
154 /// </returns>
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
155 protected abstract ICollection<IWarFoundryObject> DoCreateObjectsFromFile(FILE_TYPE file);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
156
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 protected void OnGameSystemLoaded(GameSystem system)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159 if (GameSystemLoaded != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
160 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161 GameSystemLoaded(system);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 protected void OnRaceLoaded(Race race)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167 if (RaceLoaded != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 RaceLoaded(race);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173 protected void OnArmyLoaded(Army army)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175 if (ArmyLoaded != null)
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 {
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 ArmyLoaded(army);
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
179 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
180 }
3c4a6403a88c * Fix capitalisation so that new files are in the namespace
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
181 }