Mercurial > repos > IBDev-IBBoard.WarFoundry.API
annotate api/Factories/Xml/WarFoundryXmlElementName.cs @ 128:45a9452579a2
Fixes #50: Complete core loading of WarFoundry XML files
* Add exceptions on invalid data - completes WarFoundry 0.1 loading needs
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 26 Aug 2009 18:37:55 +0000 |
parents | 2f3cafb69799 |
children | cd657faa0c05 |
rev | line source |
---|---|
15 | 1 // This file (WarFoundryXmlElementName.cs) is a part of the IBBoard.WarFoundry.API project and is copyright 2009 IBBoard. |
0 | 2 // |
104
2f3cafb69799
Re #121: Migrate to AGPL license
IBBoard <dev@ibboard.co.uk>
parents:
15
diff
changeset
|
3 // 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. |
0 | 4 |
5 using System; | |
6 using System.Collections.Generic; | |
7 using IBBoard.Xml; | |
8 | |
9 namespace IBBoard.WarFoundry.API.Factories.Xml | |
10 { | |
11 /// <summary> | |
12 /// An enumeration class for valid WarFoundry XML elements, designed to imitate Java's extensible complex object enumerations. | |
13 /// </summary> | |
14 public class WarFoundryXmlElementName : IXmlElementName, IExtendedEnum<string> | |
15 { | |
16 public static WarFoundryXmlElementName SYSTEM_ELEMENT = new WarFoundryXmlElementName("SYSTEM_ELEMENT", "system"); | |
17 public static WarFoundryXmlElementName ARMY_ELEMENT = new WarFoundryXmlElementName("ARMY_ELEMENT", "army"); | |
18 public static WarFoundryXmlElementName RACE_ELEMENT = new WarFoundryXmlElementName("RACE_ELEMENT", "race"); | |
19 public static WarFoundryXmlElementName CATEGORIES_ELEMENT = new WarFoundryXmlElementName("CATEGORIES_ELEMENT", "categories"); | |
20 public static WarFoundryXmlElementName CATEGORY_ELEMENT = new WarFoundryXmlElementName("CATEGORY_ELEMENT", "cat"); | |
21 public static WarFoundryXmlElementName UNITTYPES_ELEMENT = new WarFoundryXmlElementName("UNITTYPES_ELEMENT", "units"); | |
22 public static WarFoundryXmlElementName UNITTYPE_ELEMENT = new WarFoundryXmlElementName("UNITTYPE_ELEMENT", "unit"); | |
23 public static WarFoundryXmlElementName RACE_EQUIPMENT_ITEMS_ELEMENT = new WarFoundryXmlElementName("RACE_EQUIPMENT_ITEMS_ELEMENT", "equipment"); | |
24 public static WarFoundryXmlElementName RACE_EQUIPMENT_ITEM_ELEMENT = new WarFoundryXmlElementName("RACE_EQUIPMENT_ITEMS_ELEMENT", "equipmentItem"); | |
25 | |
26 private static ICollection<WarFoundryXmlElementName> enumValues; | |
27 private string name; | |
28 private string val; | |
29 | |
30 private WarFoundryXmlElementName(string elemName, string elemVal) | |
31 { | |
32 name = elemName; | |
33 val = elemVal; | |
34 } | |
35 | |
36 public string Name | |
37 { | |
38 get { | |
39 return name; | |
40 } | |
41 } | |
42 | |
43 public string Value | |
44 { | |
45 get { | |
46 return val; | |
47 } | |
48 } | |
49 | |
50 /// <summary> | |
51 /// Gets an ICollection of the values so that they can be looped over like a standard enumeration. | |
52 /// </summary> | |
53 /// <returns> | |
54 /// A <see cref="ICollection`1"/> of all of the static 'enumeration' values of the class. | |
55 /// </returns> | |
56 public static ICollection<WarFoundryXmlElementName> GetEnumValues() | |
57 { | |
58 if (enumValues == null) | |
59 { | |
60 enumValues = new WarFoundryXmlElementName[]{SYSTEM_ELEMENT, ARMY_ELEMENT, RACE_ELEMENT, CATEGORIES_ELEMENT, CATEGORY_ELEMENT, UNITTYPES_ELEMENT, UNITTYPE_ELEMENT}; | |
61 } | |
62 | |
63 return enumValues; | |
64 } | |
65 } | |
66 } |