Mercurial > repos > IBDev-IBBoard.WarFoundry.API
view API/Factories/AbstractNonNativeFileExtensionWarFoundryFactory.cs @ 485:8160d1f8243c
Re #418: Build WarFoundry for Android PoC
* Make Mono for Android version of .csproj file
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 14 Jul 2012 15:26:46 +0100 |
parents | 1ed2f3ab5e35 |
children |
line wrap: on
line source
// This file (AbstractNonNativeFileExtensionWarFoundryFactory.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2007, 2008, 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.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Loading; namespace IBBoard.WarFoundry.API.Factories { public abstract class AbstractNonNativeFileExtensionWarFoundryFactory : AbstractNonNativeWarFoundryFactory<ILoadableObject> { protected abstract string ArmyFileExtension { get; } protected abstract string RaceFileExtension { get; } protected abstract string GameSystemFileExtension { get; } protected override bool CheckCanHandleFileFormat(ILoadableObject file) { return CheckCanHandleFileAsArmy(file) || CheckCanHandleFileAsRace(file) || CheckCanHandleFileAsGameSystem(file); } protected override bool CheckCanHandleFileAsArmy(ILoadableObject file) { return ArmyFileExtension != null && file.Name.ToLower().EndsWith(ArmyFileExtension); } protected override bool CheckCanHandleFileAsRace(ILoadableObject file) { return RaceFileExtension != null && file.Name.ToLower().EndsWith(RaceFileExtension); } protected override bool CheckCanHandleFileAsGameSystem(ILoadableObject file) { return GameSystemFileExtension != null && file.Name.ToLower().EndsWith(GameSystemFileExtension); } protected override ILoadableObject GetFileAsSupportedType(ILoadableObject file) { return file; } protected abstract Army CreateArmyFromFile(ILoadableObject file); protected abstract Race CreateRaceFromFile(ILoadableObject file); protected abstract GameSystem CreateGameSystemFromFile(ILoadableObject file); protected override ICollection<IWarFoundryObject> DoCreateObjectsFromFile(ILoadableObject file) { IWarFoundryObject obj = null; if (CheckCanHandleFileAsGameSystem(file)) { GameSystem gameSystem = CreateGameSystemFromFile(file); OnGameSystemLoaded(gameSystem); obj = gameSystem; } else if (CheckCanHandleFileAsRace(file)) { Race race = CreateRaceFromFile(file); OnRaceLoaded(race); obj = race; } else //Must have been an army file { Army army = CreateArmyFromFile(file); OnArmyLoaded(army); obj = army; } ICollection<IWarFoundryObject> objects = new List<IWarFoundryObject>(); if (obj != null) { objects.Add(obj); } return objects; } } }