Mercurial > repos > IBBoard.WarFoundry.API
diff 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 |
line wrap: on
line diff
--- a/api/Factories/AbstractWarFoundryFactory.cs Sat Sep 26 10:43:28 2009 +0000 +++ b/api/Factories/AbstractWarFoundryFactory.cs Sat Sep 26 18:48:36 2009 +0000 @@ -19,26 +19,59 @@ public bool CanHandleFileFormat (FileInfo file) { - FILE_TYPE typedFile = GetFileAsSupportedType(file); - return typedFile != null && CheckCanHandleFileFormat(typedFile); + FILE_TYPE typedFile = GetFileAsSupportedType(file); + bool canHandle = typedFile != null && CheckCanHandleFileFormat(typedFile); + + if (typedFile != null) + { + CleanUpFileAsSupportedType(typedFile); + } + + return canHandle; } public bool CanHandleFileAsRace(FileInfo file) { - FILE_TYPE typedFile = GetFileAsSupportedType(file); - return typedFile != null && CheckCanHandleFileAsRace(typedFile); + FILE_TYPE typedFile = GetFileAsSupportedType(file); + bool canHandle = typedFile != null && CheckCanHandleFileAsRace(typedFile); + + if (typedFile != null) + { + CleanUpFileAsSupportedType(typedFile); + } + + return canHandle; } public bool CanHandleFileAsGameSystem(FileInfo file) { - FILE_TYPE typedFile = GetFileAsSupportedType(file); - return typedFile != null && CheckCanHandleFileAsGameSystem(typedFile); + FILE_TYPE typedFile = GetFileAsSupportedType(file); + bool canHandle = typedFile != null && CheckCanHandleFileAsGameSystem(typedFile); + + if (typedFile != null) + { + CleanUpFileAsSupportedType(typedFile); + } + + return canHandle; } public bool CanHandleFileAsArmy(FileInfo file) { FILE_TYPE typedFile = GetFileAsSupportedType(file); - return typedFile != null && CheckCanHandleFileAsArmy(typedFile); + bool canHandle = typedFile != null && CheckCanHandleFileAsArmy(typedFile); + + if (typedFile != null) + { + CleanUpFileAsSupportedType(typedFile); + } + + return canHandle; + } + + protected virtual void CleanUpFileAsSupportedType(FILE_TYPE typedFile) + { + //Do nothing by default } /// <summary>