Mercurial > repos > IBBoard.WarFoundry.API
diff api/FileLoadFailure.cs @ 14:0770e5cbba7c
Closes #21 - File loading in order
* Reworked LoadFiles to smaller methods for readability (also re #10) and structure
* Now determine expected load return before loading then load all "expected GameSystem" before "expected Race"
* Make "can load as race/game system/army" methods public in interface
Re #22 - Get errored file loading
* Created FileLoadFailure class and made LoadFiles return a list of them
Also
* Some code cleanup
* Change to DictionaryUtils calls
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 25 Jan 2009 14:03:20 +0000 |
parents | |
children | 306558904c2a |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api/FileLoadFailure.cs Sun Jan 25 14:03:20 2009 +0000 @@ -0,0 +1,68 @@ +// This file (FileLoadFailure.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. +// +// The file and the library/program it is in are licensed under the GNU LGPL license. Please see COPYING.LGPL for more information and the full license. + +using System; +using System.IO; +using IBBoard.Lang; +using IBBoard.WarFoundry.API.Factories; + +namespace IBBoard.WarFoundry.API +{ + public class FileLoadFailure + { + private FileInfo failedFile; + private IWarFoundryFactory loadingFactory; + private string defaultMessage; + private string messageTranslationID; + private string message; + + public FileLoadFailure(FileInfo file, string message) : this (file, message, "") + { + } + + public FileLoadFailure(FileInfo file, string message, string translationID) : this (file, null, message, "") + { + } + + public FileLoadFailure(FileInfo file, IWarFoundryFactory factory, string message) : this (file, factory, message, "") + { + } + + public FileLoadFailure(FileInfo file,IWarFoundryFactory factory, string message, string translationID) + { + failedFile = file; + loadingFactory = factory; + defaultMessage = message; + messageTranslationID = translationID; + } + + public FileInfo FailedFile + { + get + { + return failedFile; + } + } + + public string Message + { + get + { + if (message == null) + { + if (messageTranslationID == "") + { + message = String.Format(defaultMessage, FailedFile, loadingFactory); + } + else + { + message = Translation.GetTranslation(messageTranslationID, defaultMessage, failedFile, loadingFactory); + } + } + + return message; + } + } + } +}