changeset 30:92cf25b0493b

Re #32 - Migrate to using Schemas * Replace decimal with double to try to get around type cast issues * Correct schema to use minNum and maxNum instead of min/maxNumber for attributes * Use new FileLoadFailure parameters to better log errors while loading files
author IBBoard <dev@ibboard.co.uk>
date Sat, 14 Mar 2009 20:16:09 +0000
parents d7899f462d8c
children 457c9357dd64
files api/WarFoundryLoader.cs dtds/race.xsd dtds/warfoundry-core.xsd
diffstat 3 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/api/WarFoundryLoader.cs	Sat Mar 14 20:14:07 2009 +0000
+++ b/api/WarFoundryLoader.cs	Sat Mar 14 20:16:09 2009 +0000
@@ -204,7 +204,9 @@
 					}
 					else
 					{
-						fails.Add(new FileLoadFailure(file, "FileNotHandled", "File not handled as a Race or Game System definition: {0}"));
+						FileLoadFailure failure = new FileLoadFailure(file, "File not handled as a Race or Game System definition: {0}", "FileNotHandled");
+						fails.Add(failure);
+						LogNotifier.Info(GetType(), failure.Message);
 					}
 				}
 			}
@@ -288,7 +290,7 @@
 				}
 				catch (Exception ex)
 				{
-					failure = new FileLoadFailure(file, ex.Message);
+					failure = new FileLoadFailure(file, null, ex.Message, null, ex);
 				}
 						
 				if (failure!=null)
@@ -320,13 +322,13 @@
 				}
 				catch (Exception ex)
 				{
-					failure = new FileLoadFailure(file, ex.Message);
+					failure = new FileLoadFailure(file, null, ex.Message, null, ex);
 				}
 						
 				if (failure!=null)
 				{
 					fails.Add(failure);
-					LogNotifier.Warn(GetType(), failure.Message);
+					LogNotifier.Warn(GetType(), failure.Message, failure.Exception);
 				}
 			}
 			
--- a/dtds/race.xsd	Sat Mar 14 20:14:07 2009 +0000
+++ b/dtds/race.xsd	Sat Mar 14 20:16:09 2009 +0000
@@ -35,8 +35,8 @@
   <xs:attribute name="cat" type="xs:string" use="required"/>
   <xs:attribute name="unitPoints" type="core:nonNegativeDecimal" default="0"/>
   <xs:attribute name="points" type="core:nonNegativeDecimal" use="required"/>
-  <xs:attribute name="minNumber" type="xs:nonNegativeInteger" default="0"/>
-  <xs:attribute name="maxNumber" type="core:infiniteOrNonNegativeInteger" default="-1"/>
+  <xs:attribute name="minNum" type="xs:nonNegativeInteger" default="0"/>
+  <xs:attribute name="maxNum" type="core:infiniteOrNonNegativeInteger" default="-1"/>
   <xs:attribute name="minSize" type="xs:positiveInteger" default="5"/>
   <xs:attribute name="maxSize" type="core:infiniteOrNonNegativeInteger" default="-1"/>
   <xs:attribute name="baseSize" type="xs:nonNegativeInteger" default="0"/>
@@ -62,8 +62,8 @@
   <xs:attribute name="equipID" type="xs:IDREF" />
   <xs:attribute name="required" type="xs:boolean" default="false"/>
   <xs:attribute name="exclusivityGroup" type="xs:string" default=""/>
-  <xs:attribute name="minNumber" type="core:infiniteOrNonNegativeInteger" default="-1"/>
-  <xs:attribute name="maxNumber" type="core:infiniteOrNonNegativeInteger" default="-1"/>
+  <xs:attribute name="minNum" type="core:infiniteOrNonNegativeInteger" default="-1"/>
+  <xs:attribute name="maxNum" type="core:infiniteOrNonNegativeInteger" default="-1"/>
   <xs:attribute name="minPercentage" type="core:percentage" default="100"/>
   <xs:attribute name="maxPercentage" type="core:percentage" default="100"/>
   <xs:attribute name="roundDirection" type="updowntype" default="up"/>
--- a/dtds/warfoundry-core.xsd	Sat Mar 14 20:14:07 2009 +0000
+++ b/dtds/warfoundry-core.xsd	Sat Mar 14 20:16:09 2009 +0000
@@ -2,7 +2,7 @@
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ibboard.co.uk/warfoundry/core"
 xmlns="http://ibboard.co.uk/warfoundry/core" elementFormDefault="qualified">
 <xs:simpleType name="infiniteOrNonNegativeDecimal">
-  <xs:restriction base="xs:decimal">
+  <xs:restriction base="xs:double">
     <xs:minInclusive value="-1"/>
   </xs:restriction>
 </xs:simpleType>
@@ -12,12 +12,12 @@
   </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="nonNegativeDecimal">
-  <xs:restriction base="xs:decimal">
+  <xs:restriction base="xs:double">
     <xs:minInclusive value="0"/>
   </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="percentage">
-  <xs:restriction base="xs:decimal">
+  <xs:restriction base="xs:double">
     <xs:minInclusive value="0"/>
     <xs:maxInclusive value="100"/>
   </xs:restriction>