diff API/AbstractWarFoundryLoader.cs @ 463:cbeee87dc2d3

Re #58: Remove LogNotifier from API * Remove LogNotifier from API - mostly unnecessary logging Also: * Formatting auto-corrected * LoadFile() "try...catch {silently dispose}" removed. Code shouldn't be throwing those errors and needs to be handled elsewhere if it does
author IBBoard <dev@ibboard.co.uk>
date Sat, 17 Mar 2012 20:02:32 +0000
parents 86725e88052e
children 1a632b133606
line wrap: on
line diff
--- a/API/AbstractWarFoundryLoader.cs	Tue Mar 06 20:31:31 2012 +0000
+++ b/API/AbstractWarFoundryLoader.cs	Sat Mar 17 20:02:32 2012 +0000
@@ -1,13 +1,11 @@
 // This file (AbstractWarFoundryLoader.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 and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.
-
 using System;
 using System.Collections.Generic;
 using System.IO;
 using IBBoard.Collections;
 using IBBoard.IO;
-using IBBoard.Logging;
 using IBBoard.WarFoundry.API.Factories;
 using IBBoard.WarFoundry.API.Objects;
 
@@ -26,7 +24,6 @@
 		public delegate void FileLoadingCompleteDelegate(List<FileLoadFailure> failures);
 
 		public event MethodInvoker FileLoadingStarted;
-
 		public event FileLoadingCompleteDelegate FileLoadingFinished;
 
 		protected AbstractWarFoundryLoader()
@@ -180,10 +177,6 @@
 					List<FileLoadFailure> directoryFails = FillLoadableFilesForDirectory(loadableRaces, loadableGameSystems, directory);
 					fails.AddRange(directoryFails);
 				}
-				else
-				{
-					LogNotifier.WarnFormat(GetType(), "Load for {0} failed because directory didn't exist", directory.FullName);
-				}
 			}
 			
 			return fails;
@@ -192,7 +185,6 @@
 		private List<FileLoadFailure> FillLoadableFilesForDirectory(Dictionary<FileInfo, IWarFoundryFactory> loadableRaces, Dictionary<FileInfo, IWarFoundryFactory> loadableGameSystems, DirectoryInfo directory)
 		{
 			List<FileLoadFailure> fails = new List<FileLoadFailure>();
-			LogNotifier.Debug(GetType(), "Load from " + directory.FullName);
 		
 			foreach (FileInfo file in directory.GetFiles())
 			{
@@ -214,7 +206,6 @@
 					{
 						FileLoadFailure failure = new FileLoadFailure(file, "File not handled as a Race or Game System definition: {0}", "FileNotHandled");
 						fails.Add(failure);
-						LogNotifier.Info(GetType(), failure.Message);
 					}
 				}
 			}
@@ -309,7 +300,6 @@
 				if (failure != null)
 				{
 					fails.Add(failure);
-					LogNotifier.Warn(GetType(), failure.Message, failure.Exception);
 				}
 			}
 			
@@ -341,7 +331,6 @@
 				if (failure != null)
 				{
 					fails.Add(failure);
-					LogNotifier.Warn(GetType(), failure.Message, failure.Exception);
 				}
 			}
 			
@@ -350,9 +339,8 @@
 
 		private bool LoadObject(FileInfo file, IWarFoundryFactory factory)
 		{
-			LogNotifier.DebugFormat(GetType(), "Loading {0} using {1}", file.FullName, factory.GetType().Name);
-			factory.RaceLoaded+= StoreRace;
-			factory.GameSystemLoaded+= StoreGameSystem;
+			factory.RaceLoaded += StoreRace;
+			factory.GameSystemLoaded += StoreGameSystem;
 			ICollection<IWarFoundryObject> objects = factory.CreateObjectsFromFile(file);
 			return objects.Count > 0;
 		}
@@ -369,21 +357,12 @@
 		/// </returns>
 		public ICollection<IWarFoundryObject> LoadFile(FileInfo file)
 		{
-			ICollection<IWarFoundryObject> objs = null;
 			IWarFoundryFactory loadFactory = null;
-			
-			try
-			{
-				objs = LoadFileWithNonNativeFactories(file, out loadFactory);
+			ICollection<IWarFoundryObject> objs = LoadFileWithNonNativeFactories(file, out loadFactory);
 				
-				if (objs == null)
-				{
-					objs = LoadFileWithNativeFactories(file, out loadFactory);
-				}
-			}
-			catch (InvalidFileException ex)
+			if (objs == null)
 			{
-				LogNotifier.Error(GetType(), file.FullName + " failed to load", ex);
+				objs = LoadFileWithNativeFactories(file, out loadFactory);
 			}
 				
 			if (objs != null)
@@ -405,12 +384,9 @@
 			
 			if (nonNativeFactories.Count > 0)
 			{
-				LogNotifier.Debug(GetType(), "Attempting to load " + file.FullName + " as a non-native file");
-				
 				foreach (INonNativeWarFoundryFactory factory in nonNativeFactories)
 				{
 					bool canLoad = factory.CanHandleFileFormat(file);
-					LogNotifier.Debug(GetType(), "Load using " + factory.GetType().FullName + "? " + (canLoad ? "yes" : "no"));
 					
 					if (canLoad)
 					{
@@ -435,8 +411,6 @@
 			
 			if (factories.Count > 0)
 			{
-				LogNotifier.Debug(GetType(), "Attempting to load " + file.FullName + " as native file");
-						
 				foreach (INativeWarFoundryFactory factory in factories)
 				{
 					if (factory.CanHandleFileFormat(file))