Mercurial > repos > IBDev-IBBoard.WarFoundry.API
diff api/Factories/Xml/WarFoundryXmlFactory.cs @ 40:3664eee50390
Fixes #47 - remove magic numbers
* Create "infinity" in core types
* Redefine special core types without trying to use non-existant INF for Integers
* Use new types in Cats and Race
* Remove special handling of INF when parsing an integer attribute
Closes #46 - Resolve problems using custom restrictions of decimal and double
* New schemas seem to work without exceptioning
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 21 Mar 2009 17:04:33 +0000 |
parents | 05c6745cc660 |
children | 422ddd5fedd1 |
line wrap: on
line diff
--- a/api/Factories/Xml/WarFoundryXmlFactory.cs Thu Mar 19 20:12:29 2009 +0000 +++ b/api/Factories/Xml/WarFoundryXmlFactory.cs Sat Mar 21 17:04:33 2009 +0000 @@ -381,26 +381,14 @@ private int GetIntValueFromAttribute(XmlElement elem, string attributeName) { - string attribValue = elem.GetAttribute(attributeName); - int intValue = int.MaxValue; - - if ("INF".Equals(attribValue)) - { - intValue = WarFoundryCore.INFINITY; - } - else + try { - try - { - intValue = int.Parse(attribValue); - } - catch(FormatException) - { - throw new FormatException(String.Format("Attribute '{0}' of {1} with ID {2} was not a valid number", attributeName, elem.Name, elem.GetAttribute("id"))); - } + return int.Parse(elem.GetAttribute(attributeName)); } - - return intValue; + catch(FormatException) + { + throw new FormatException(String.Format("Attribute '{0}' of {1} with ID {2} was not a valid number", attributeName, elem.Name, elem.GetAttribute("id"))); + } } private UnitType CreateUnitTypeFromElement(XmlElement elem, Race parentRace, GameSystem system)