diff API/FileLoadFailure.cs @ 482:1ed2f3ab5e35

Re #419: Remove assumptions of a file-based install * Swap API to using new "loadable object" and "loadable object source" wrappers to allow file-based or memory-based loading
author IBBoard <dev@ibboard.co.uk>
date Sat, 07 Jul 2012 21:01:32 +0100
parents 6da9db4a9c23
children
line wrap: on
line diff
--- a/API/FileLoadFailure.cs	Mon Jun 25 21:04:02 2012 +0100
+++ b/API/FileLoadFailure.cs	Sat Jul 07 21:01:32 2012 +0100
@@ -6,6 +6,7 @@
 using System.IO;
 using IBBoard.Lang;
 using IBBoard.WarFoundry.API.Factories;
+using IBBoard.WarFoundry.API.Loading;
 
 namespace IBBoard.WarFoundry.API
 {
@@ -14,7 +15,7 @@
 	/// </summary>
 	public class FileLoadFailure
 	{
-		private FileInfo failedFile;
+		private ILoadableObject failedFile;
 		private IWarFoundryFactory loadingFactory;
 		private string defaultMessage;
 		private string messageTranslationID;
@@ -25,7 +26,7 @@
 		/// Constructor for a failed file load where no factory was found. Translatable messages can be providied through a <code>translationID</code> or skipped by passing <code>null</code>.
 		/// </summary>
 		/// <param name="file">
-		/// The <see cref="FileInfo"/> that failed to load
+		/// The <see cref="ILoadableObject"/> that failed to load
 		/// </param>
 		/// <param name="message">
 		/// A message about the failure in English - used as a default fall-back message.
@@ -33,7 +34,7 @@
 		/// <param name="translationID">
 		/// The ID of a translation for the message.
 		/// </param>
-		public FileLoadFailure(FileInfo file, string message, string translationID) : this (file, null, message, "")
+		public FileLoadFailure(ILoadableObject file, string message, string translationID) : this (file, null, message, "")
 		{
 		}
 		
@@ -41,7 +42,7 @@
 		/// Constructor for a failed file load where a factory was identified as supporting the file but failed to load it. Translatable messages can be providied through a <code>translationID</code> or skipped by passing <code>null</code>.
 		/// </summary>
 		/// <param name="file">
-		/// The <see cref="FileInfo"/> that failed to load
+		/// The <see cref="ILoadableObject"/> that failed to load
 		/// </param>
 		/// <param name="factory">
 		/// The <see cref="IWarFoundryFactory"/> that failed to load the file
@@ -52,7 +53,7 @@
 		/// <param name="translationID">
 		/// The ID of a translation for the message.
 		/// </param>
-		public FileLoadFailure(FileInfo file, IWarFoundryFactory factory, string message, string translationID) : this(file, factory, message, translationID, null)
+		public FileLoadFailure(ILoadableObject file, IWarFoundryFactory factory, string message, string translationID) : this(file, factory, message, translationID, null)
 		{
 		}
 		
@@ -60,7 +61,7 @@
 		/// Constructor for a failed file load where a factory was identified as supporting the file but an exception occurred while loading it. Translatable messages can be providied through a <code>translationID</code> or skipped by passing <code>null</code>.
 		/// </summary>
 		/// <param name="file">
-		/// The <see cref="FileInfo"/> that failed to load
+		/// The <see cref="ILoadableObject"/> that failed to load
 		/// </param>
 		/// <param name="factory">
 		/// The <see cref="IWarFoundryFactory"/> that failed to load the file
@@ -74,7 +75,7 @@
 		/// <param name="exception">
 		/// The <see cref="Exception"/> that occurred to cause the load to fail
 		/// </param>
-		public FileLoadFailure(FileInfo file, IWarFoundryFactory factory, string message, string translationID, Exception exception)
+		public FileLoadFailure(ILoadableObject file, IWarFoundryFactory factory, string message, string translationID, Exception exception)
 		{
 			failedFile = file;
 			loadingFactory = factory;
@@ -83,7 +84,7 @@
 			cause = exception;
 		}
 
-		public FileInfo FailedFile
+		public ILoadableObject FailedFile
 		{
 			get
 			{
@@ -97,14 +98,14 @@
 			{
 				if (message == null)
 				{
-					string fileName = FailedFile.FullName;
+					string fileName = FailedFile.Name;
 					string factoryType = (loadingFactory == null ? "" : loadingFactory.GetType().Name);
 					if (String.IsNullOrEmpty(messageTranslationID))
 					{
 						message = String.Format(defaultMessage, fileName, factoryType);
-				 	}
+					}
 					else
-				 	{
+					{
 						message = Translation.GetTranslation(messageTranslationID, defaultMessage, fileName, factoryType);
 					}
 				}