view api/Factories/Xml/WarFoundryXmlElementName.cs @ 0:520818033bb6

Initial commit of WarFoundry code
author IBBoard <dev@ibboard.co.uk>
date Fri, 19 Dec 2008 15:57:51 +0000
parents
children 306558904c2a
line wrap: on
line source

// WarFoundryXmlElementNames.cs
//
//  Copyright (C) 2007 IBBoard
//
// This library 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 2.1 of the License, or (at your option) any later version.
//
// This library 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 library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
//
//

using System;
using System.Collections.Generic;
using IBBoard.Xml;

namespace IBBoard.WarFoundry.API.Factories.Xml
{
	/// <summary>
	/// An enumeration class for valid WarFoundry XML elements, designed to imitate Java's extensible complex object enumerations. 
	/// </summary>
	public class WarFoundryXmlElementName : IXmlElementName, IExtendedEnum<string>
	{
		public static WarFoundryXmlElementName SYSTEM_ELEMENT = new WarFoundryXmlElementName("SYSTEM_ELEMENT", "system");
		public static WarFoundryXmlElementName ARMY_ELEMENT = new WarFoundryXmlElementName("ARMY_ELEMENT", "army");
		public static WarFoundryXmlElementName RACE_ELEMENT = new WarFoundryXmlElementName("RACE_ELEMENT", "race");
		public static WarFoundryXmlElementName CATEGORIES_ELEMENT = new WarFoundryXmlElementName("CATEGORIES_ELEMENT", "categories");
		public static WarFoundryXmlElementName CATEGORY_ELEMENT = new WarFoundryXmlElementName("CATEGORY_ELEMENT", "cat");
		public static WarFoundryXmlElementName UNITTYPES_ELEMENT = new WarFoundryXmlElementName("UNITTYPES_ELEMENT", "units");
		public static WarFoundryXmlElementName UNITTYPE_ELEMENT = new WarFoundryXmlElementName("UNITTYPE_ELEMENT", "unit");
		public static WarFoundryXmlElementName RACE_EQUIPMENT_ITEMS_ELEMENT = new WarFoundryXmlElementName("RACE_EQUIPMENT_ITEMS_ELEMENT", "equipment");
		public static WarFoundryXmlElementName RACE_EQUIPMENT_ITEM_ELEMENT = new WarFoundryXmlElementName("RACE_EQUIPMENT_ITEMS_ELEMENT", "equipmentItem");
		
		private static ICollection<WarFoundryXmlElementName> enumValues;
		private string name;
		private string val;
		
		private WarFoundryXmlElementName(string elemName, string elemVal)
		{
			name = elemName;
			val = elemVal;
		}
		
		public string Name
		{
			get {
				return name;
			}
		}
		
		public string Value
		{
			get {
				return val;
			}
		}
		
		/// <summary>
		/// Gets an ICollection of the values so that they can be looped over like a standard enumeration.
		/// </summary>
		/// <returns>
		/// A <see cref="ICollection`1"/> of all of the static 'enumeration' values of the class.
		/// </returns>
		public static ICollection<WarFoundryXmlElementName> GetEnumValues()
		{
			if (enumValues == null)
			{
				enumValues = new WarFoundryXmlElementName[]{SYSTEM_ELEMENT, ARMY_ELEMENT, RACE_ELEMENT, CATEGORIES_ELEMENT, CATEGORY_ELEMENT, UNITTYPES_ELEMENT, UNITTYPE_ELEMENT};
			}
			
			return enumValues;
		}
	}
}