annotate api/Factories/AbstractNativeWarFoundryFactory.cs @ 236:ca2905c9b225

Fixes #252: Remove need for text in zip file comments * Made checks work on just content rather than zip comment to determine what file type it is * Remove public static strings with comment strings in them
author IBBoard <dev@ibboard.co.uk>
date Sat, 20 Feb 2010 20:57:13 +0000
parents fe5a03d73918
children 3854c26073c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 82
diff changeset
1 // This file (AbstractNativeWarFoundryFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 2009 IBBoard.
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
104
2f3cafb69799 Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents: 82
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.
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;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
6 using System.IO;
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using System.Xml;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using System.Xml.Schema;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using System.Collections.Generic;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 using System.Text;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 using IBBoard;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 using IBBoard.IO;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 using IBBoard.Lang;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 using IBBoard.Logging;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 using IBBoard.Xml;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 using IBBoard.WarFoundry.API.Objects;
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
17 using ICSharpCode.SharpZipLib.Zip;
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
18
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
19 namespace IBBoard.WarFoundry.API.Factories
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
20 {
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
21 /// <summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
22 /// Base abstract class for all factories that load native WarFoundry data.
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
23 /// </summary>
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
24 public abstract class AbstractNativeWarFoundryFactory : AbstractWarFoundryFactory<ZipFile>, INativeWarFoundryFactory
236
ca2905c9b225 Fixes #252: Remove need for text in zip file comments
IBBoard <dev@ibboard.co.uk>
parents: 223
diff changeset
25 {
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
26 protected AbstractNativeWarFoundryFactory()
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 {
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
28 //Do nothing - just make the constructor non-public
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 }
8
613bc5eaac59 Re #9 - Make WarFoundry loading granular
IBBoard <dev@ibboard.co.uk>
parents: 7
diff changeset
30
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 protected override ZipFile GetFileAsSupportedType (FileInfo file)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 ZipFile zip = null;
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 try
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 zip = new ZipFile(file.FullName);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 }
7
895c8a2378a1 Code cleanup - remove warning about unused exception
IBBoard <dev@ibboard.co.uk>
parents: 0
diff changeset
39 catch(ZipException)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 {
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
41 //Silently dispose as per spec for the method
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 }
27
e7de5c96f5c2 Re #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
43 catch (IOException)
e7de5c96f5c2 Re #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
44 {
e7de5c96f5c2 Re #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
45 //Silently dispose as per spec for the method
e7de5c96f5c2 Re #44 - Fix API tests
IBBoard <dev@ibboard.co.uk>
parents: 15
diff changeset
46 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 return zip;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51 protected override bool CheckCanHandleFileFormat (ZipFile file)
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
52 {
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
53 return CheckCanHandleFileAsGameSystem(file) || CheckCanHandleFileAsRace(file) || CheckCanHandleFileAsArmy(file);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
56 protected override bool CheckCanHandleFileAsGameSystem(ZipFile file)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 {
236
ca2905c9b225 Fixes #252: Remove need for text in zip file comments
IBBoard <dev@ibboard.co.uk>
parents: 223
diff changeset
58 return CheckCanFindSystemFileContent(file);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
59 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
60
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
61 protected abstract bool CheckCanFindSystemFileContent(ZipFile file);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
62
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
63 protected override bool CheckCanHandleFileAsRace(ZipFile file)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
64 {
236
ca2905c9b225 Fixes #252: Remove need for text in zip file comments
IBBoard <dev@ibboard.co.uk>
parents: 223
diff changeset
65 return CheckCanFindRaceFileContent(file);
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
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
68 protected abstract bool CheckCanFindRaceFileContent(ZipFile file);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
69
14
0770e5cbba7c Closes #21 - File loading in order
IBBoard <dev@ibboard.co.uk>
parents: 8
diff changeset
70 protected override bool CheckCanHandleFileAsArmy(ZipFile file)
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
71 {
236
ca2905c9b225 Fixes #252: Remove need for text in zip file comments
IBBoard <dev@ibboard.co.uk>
parents: 223
diff changeset
72 return CheckCanFindArmyFileContent(file);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
73 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
74
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
75 protected abstract bool CheckCanFindArmyFileContent(ZipFile file);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
76
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
77 protected override ICollection<IWarFoundryObject> DoCreateObjectsFromFile (ZipFile file)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
78 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
79 ICollection<IWarFoundryObject> objects = null;
200
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
80 IWarFoundryObject obj = null;
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
81
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
82 try
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
83 {
236
ca2905c9b225 Fixes #252: Remove need for text in zip file comments
IBBoard <dev@ibboard.co.uk>
parents: 223
diff changeset
84 if (CheckCanFindSystemFileContent(file))
200
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
85 {
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
86 obj = CreateGameSystemFromFile(file);
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
87 }
236
ca2905c9b225 Fixes #252: Remove need for text in zip file comments
IBBoard <dev@ibboard.co.uk>
parents: 223
diff changeset
88 else if (CheckCanFindRaceFileContent(file))
200
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
89 {
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
90 obj = CreateRaceFromFile(file);
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
91 }
236
ca2905c9b225 Fixes #252: Remove need for text in zip file comments
IBBoard <dev@ibboard.co.uk>
parents: 223
diff changeset
92 else if (CheckCanFindArmyFileContent(file))
200
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
93 {
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
94 obj = CreateArmyFromFile(file);
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
95 }
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
96 }
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
97 finally
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
98 {
3e287b6b5244 * Line ending fixes
IBBoard <dev@ibboard.co.uk>
parents: 199
diff changeset
99 file.Close();
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
100 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
101
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
102 if (obj!=null)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
103 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
104 objects = new List<IWarFoundryObject>();
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
105 objects.Add(obj);
151
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
106 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
107
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
108 return objects;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
109 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
110
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
111 protected Army CreateArmyFromFile(ZipFile file)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
112 {
151
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
113 Stream dataStream = GetArmyDataStream(file);
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
114
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
115 try
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
116 {
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
117 return CreateArmyFromStream(file, dataStream);
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
118 }
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
119 finally
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
120 {
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
121 dataStream.Close();
148
8e636443aa8e Re #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 115
diff changeset
122 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
123 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
124
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
125 protected abstract Stream GetArmyDataStream(ZipFile file);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
126 protected abstract Army CreateArmyFromStream(ZipFile file, Stream dataStream);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
127
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
128 protected Race CreateRaceFromFile(ZipFile file)
151
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
129 {
148
8e636443aa8e Re #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 115
diff changeset
130 Stream dataStream = GetRaceDataStream(file);
8e636443aa8e Re #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 115
diff changeset
131
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
132 try
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
133 {
148
8e636443aa8e Re #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 115
diff changeset
134 return CreateRaceFromStream(file, dataStream);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
135 }
151
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
136 finally
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
137 {
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
138 dataStream.Close();
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
139 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
140 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
141
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
142 protected abstract Stream GetRaceDataStream(ZipFile file);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
143 protected abstract Race CreateRaceFromStream(ZipFile file, Stream dataStream);
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
144
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
145 protected GameSystem CreateGameSystemFromFile(ZipFile file)
151
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
146 {
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
147 Stream dataStream = GetGameSystemDataStream(file);
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
148
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
149 try
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
150 {
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
151 return CreateGameSystemFromStream(file, dataStream);
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
152 }
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
153 finally
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
154 {
1d13820b3d96 Fixes #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 150
diff changeset
155 dataStream.Close();
148
8e636443aa8e Re #176: Bug when saving recently edited army
IBBoard <dev@ibboard.co.uk>
parents: 115
diff changeset
156 }
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
157 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
158
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
159 protected abstract Stream GetGameSystemDataStream(ZipFile file);
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
160 protected abstract GameSystem CreateGameSystemFromStream(ZipFile file, Stream dataStream);
0
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
161
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
162 public override bool Equals (object o)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
163 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
164 if (o == this)
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
165 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
166 return true;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
167 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
168 else if (o == null || !(this.GetType().Equals(o.GetType())))
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
169 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
170 return false;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
171 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
172
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
173 return true;
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
174 }
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
175
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
176 public override int GetHashCode ()
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
177 {
520818033bb6 Initial commit of WarFoundry code
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
178 return GetType().FullName.GetHashCode();
82
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
179 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
180 }
3ea0ab04352b * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 27
diff changeset
181 }