view api/FileLoadFailure.cs @ 23:f9846f896df3

Re #32 - Migrate WarFoundry files to using Schemas * Add missing spaces to Cats and Core XSD * Fix some incorrect namespaces in Race XSD * Copy schemas to output dir on build * Make WarFoundryXmlFactory validate against Schemas * Make WarFoundryLoader handle failed file loads slightly differently so that we can log out as a warning * Correctly structure "simpleContent" sections of Race XSD Still to do: * Work out why Race XSD doesn't like core:nonNegativeDecimal but appears to be fine with core:percentage * Migrate test files to define namespaces and make sure they match the structure
author IBBoard <dev@ibboard.co.uk>
date Thu, 12 Mar 2009 21:35:17 +0000
parents 306558904c2a
children d7899f462d8c
line wrap: on
line source

// 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, either version 3 of the License or (at your option) any later version. 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;
			}
		}
	}
}