view API/EventListeningWarFoundryLoader.cs @ 172:c026c02583ca

* Remove MockArmy.GetMockArmy as it only causes problems in unit tests * Remove MockArmyCategory as MockArmy change would make it do nothing special * Close streams as well as files to fix Windows unit test errors
author IBBoard <dev@ibboard.co.uk>
date Sat, 24 Sep 2011 11:46:20 +0100
parents 3c2c108a2f08
children 0f144576e5eb
line wrap: on
line source

using System;
using IBBoard.WarFoundry.API.Factories;
using System.Collections.Generic;
using IBBoard.WarFoundry.API.Objects;

namespace IBBoard.WarFoundry.API
{
	public class EventListeningWarFoundryLoader : AbstractWarFoundryLoader
	{
		private IDictionary<string, GameSystem> gameSystems;
		private IDictionary<string, Race> races;
		private IDictionary<string, Army> armies;

		public EventListeningWarFoundryLoader()
		{
			gameSystems = new Dictionary<string, GameSystem>();
			races = new Dictionary<string, Race>();
			armies = new Dictionary<string, Army>();
		}
		
		public override void RegisterFactory (INativeWarFoundryFactory factory)
		{
			base.RegisterFactory (factory);
			factory.GameSystemLoaded+= DoStoreGameSystem;
			factory.RaceLoaded+= DoStoreRace;
		}
		
		public override void UnregisterFactory (INativeWarFoundryFactory factory)
		{
			base.UnregisterFactory(factory);
			factory.GameSystemLoaded-= DoStoreGameSystem;
			factory.RaceLoaded-= DoStoreRace;
		}
		
		protected override GameSystem GetExistingSystemForSystem (GameSystem system)
		{
			throw new System.NotImplementedException();
		}
		
		
		protected override void DoStoreGameSystem (GameSystem system)
		{
			gameSystems.Add(system.ID, system);
		}
		
		
		protected override void DoStoreRace (Race race)
		{
			races.Add(race.GameSystem.ID + race.ID, race);
		}
		
		
		public override GameSystem[] GetGameSystems ()
		{
			throw new System.NotImplementedException();
		}
		
		
		public override GameSystem GetGameSystem (string systemID)
		{
			return DictionaryUtils.GetValue(gameSystems, systemID);
		}
		
		
		protected override void RemoveGameSystem (GameSystem system)
		{
			throw new System.NotImplementedException();
		}
		
		
		public override Race[] GetRaces (GameSystem system)
		{
			throw new System.NotImplementedException();
		}
		
		
		public override Race GetRace (GameSystem system, string raceID)
		{
			return GetRace(system, raceID, "");
		}
		
		
		public override Race GetRace (GameSystem system, string raceID, string raceSubID)
		{
			return DictionaryUtils.GetValue(races, raceID);
		}
		
		
		protected override void RemoveRace (Race race)
		{
			throw new System.NotImplementedException();
		}
	}
}