Mercurial > repos > IBDev-IBBoard.WarFoundry.API
view api/Objects/WarFoundryStagedLoadingObject.cs @ 11:5a1df00b0359
Re #9 - Make WarFoundry API load files in small methods
* Add "add unit type" and "add equipment" methods to Race
* Deprecate old "set unit types" and "set equipment" methods on Race
* Update WarFoundryXmlFactory to use new methods
* Create DuplicateItemException for later use
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 18 Jan 2009 16:24:03 +0000 |
parents | 613bc5eaac59 |
children | 306558904c2a |
line wrap: on
line source
// WarFoundryStagedLoadingObject.cs is a part of the IBBoard.WarFoundry.API library (referred to from here as "this program") // // Copyright (C) 2009 IBBoard // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. // using System; using System.IO; using IBBoard.WarFoundry.API.Factories; namespace IBBoard.WarFoundry.API.Objects { public class WarFoundryStagedLoadingObject : WarFoundryObject, IWarFoundryStagedLoadObject { private bool isFullyLoaded; private IWarFoundryFactory creatingFactory; private FileInfo sourceFile; protected WarFoundryStagedLoadingObject(IWarFoundryFactory creatingFactory) : this (null, creatingFactory) { } protected WarFoundryStagedLoadingObject(string objName, IWarFoundryFactory creatingFactory) : this(null, objName, creatingFactory) { } protected WarFoundryStagedLoadingObject(string objId, string objName, IWarFoundryFactory creatingFactory) : base(objId, objName) { this.creatingFactory = creatingFactory; isFullyLoaded = false; } public FileInfo SourceFile { get { return sourceFile; } set { sourceFile = value; } } public void EnsureFullyLoaded () { if (!IsFullyLoaded) { if (Factory == null) { throw new InvalidOperationException("No factory set for partially loaded object with ID "+ID); } Factory.CompleteLoading(this); } } public IWarFoundryFactory Factory { get { return creatingFactory; } } public bool IsFullyLoaded { get { return isFullyLoaded; } } public void SetAsFullyLoaded() { isFullyLoaded = true; } } }