Mercurial > repos > IBBoard.WarFoundry.API
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:ad8eaed12e66 | 14:0770e5cbba7c |
---|---|
1 // This file (FileLoadFailure.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. | |
2 // | |
3 // 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. | |
4 | |
5 using System; | |
6 using System.IO; | |
7 using IBBoard.Lang; | |
8 using IBBoard.WarFoundry.API.Factories; | |
9 | |
10 namespace IBBoard.WarFoundry.API | |
11 { | |
12 public class FileLoadFailure | |
13 { | |
14 private FileInfo failedFile; | |
15 private IWarFoundryFactory loadingFactory; | |
16 private string defaultMessage; | |
17 private string messageTranslationID; | |
18 private string message; | |
19 | |
20 public FileLoadFailure(FileInfo file, string message) : this (file, message, "") | |
21 { | |
22 } | |
23 | |
24 public FileLoadFailure(FileInfo file, string message, string translationID) : this (file, null, message, "") | |
25 { | |
26 } | |
27 | |
28 public FileLoadFailure(FileInfo file, IWarFoundryFactory factory, string message) : this (file, factory, message, "") | |
29 { | |
30 } | |
31 | |
32 public FileLoadFailure(FileInfo file,IWarFoundryFactory factory, string message, string translationID) | |
33 { | |
34 failedFile = file; | |
35 loadingFactory = factory; | |
36 defaultMessage = message; | |
37 messageTranslationID = translationID; | |
38 } | |
39 | |
40 public FileInfo FailedFile | |
41 { | |
42 get | |
43 { | |
44 return failedFile; | |
45 } | |
46 } | |
47 | |
48 public string Message | |
49 { | |
50 get | |
51 { | |
52 if (message == null) | |
53 { | |
54 if (messageTranslationID == "") | |
55 { | |
56 message = String.Format(defaultMessage, FailedFile, loadingFactory); | |
57 } | |
58 else | |
59 { | |
60 message = Translation.GetTranslation(messageTranslationID, defaultMessage, failedFile, loadingFactory); | |
61 } | |
62 } | |
63 | |
64 return message; | |
65 } | |
66 } | |
67 } | |
68 } |