comparison api/Factories/AbstractWarFoundryFactory.cs @ 151:1d13820b3d96

Fixes #176: Bug when saving recently edited army * Add loaded file cleanup to AbstractWarFoundryFactory * Add override of method with Zip reference closing to WarFoundryXmlFactory WarFoundry now no longer ends up with trailing handles to files, although why they only caused problems in some situations is unknown Also: * Some line ending fixes (curse cross-platform development and different line terminators!)
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Sep 2009 18:48:36 +0000
parents fcbc3beea498
children 3e287b6b5244
comparison
equal deleted inserted replaced
150:b36cc4af435b 151:1d13820b3d96
18 } 18 }
19 19
20 public bool CanHandleFileFormat (FileInfo file) 20 public bool CanHandleFileFormat (FileInfo file)
21 { 21 {
22 FILE_TYPE typedFile = GetFileAsSupportedType(file); 22 FILE_TYPE typedFile = GetFileAsSupportedType(file);
23 return typedFile != null && CheckCanHandleFileFormat(typedFile); 23 bool canHandle = typedFile != null && CheckCanHandleFileFormat(typedFile);
24
25 if (typedFile != null)
26 {
27 CleanUpFileAsSupportedType(typedFile);
28 }
29
30 return canHandle;
24 } 31 }
25 32
26 public bool CanHandleFileAsRace(FileInfo file) 33 public bool CanHandleFileAsRace(FileInfo file)
27 { 34 {
28 FILE_TYPE typedFile = GetFileAsSupportedType(file); 35 FILE_TYPE typedFile = GetFileAsSupportedType(file);
29 return typedFile != null && CheckCanHandleFileAsRace(typedFile); 36 bool canHandle = typedFile != null && CheckCanHandleFileAsRace(typedFile);
37
38 if (typedFile != null)
39 {
40 CleanUpFileAsSupportedType(typedFile);
41 }
42
43 return canHandle;
30 } 44 }
31 45
32 public bool CanHandleFileAsGameSystem(FileInfo file) 46 public bool CanHandleFileAsGameSystem(FileInfo file)
33 { 47 {
34 FILE_TYPE typedFile = GetFileAsSupportedType(file); 48 FILE_TYPE typedFile = GetFileAsSupportedType(file);
35 return typedFile != null && CheckCanHandleFileAsGameSystem(typedFile); 49 bool canHandle = typedFile != null && CheckCanHandleFileAsGameSystem(typedFile);
50
51 if (typedFile != null)
52 {
53 CleanUpFileAsSupportedType(typedFile);
54 }
55
56 return canHandle;
36 } 57 }
37 58
38 public bool CanHandleFileAsArmy(FileInfo file) 59 public bool CanHandleFileAsArmy(FileInfo file)
39 { 60 {
40 FILE_TYPE typedFile = GetFileAsSupportedType(file); 61 FILE_TYPE typedFile = GetFileAsSupportedType(file);
41 return typedFile != null && CheckCanHandleFileAsArmy(typedFile); 62 bool canHandle = typedFile != null && CheckCanHandleFileAsArmy(typedFile);
63
64 if (typedFile != null)
65 {
66 CleanUpFileAsSupportedType(typedFile);
67 }
68
69 return canHandle;
70 }
71
72 protected virtual void CleanUpFileAsSupportedType(FILE_TYPE typedFile)
73 {
74 //Do nothing by default
42 } 75 }
43 76
44 /// <summary> 77 /// <summary>
45 /// 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. 78 /// 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.
46 /// If the file is not of supported type the <code>null</code> should be returned. 79 /// If the file is not of supported type the <code>null</code> should be returned.