changeset 43:2baf3f949cfb

* Make sure that we use "." as our decimal separator when parsing doubles from XML (should fix warfoundry:#185 for Europe) * Automated cleanups no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sun, 04 Oct 2009 09:47:16 +0000
parents 7e74c7954be9
children 8725c5440606
files Commands/CommandStack.cs IBBoard.csproj Xml/XmlTools.cs
diffstat 3 files changed, 17 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Commands/CommandStack.cs	Tue Sep 29 19:19:44 2009 +0000
+++ b/Commands/CommandStack.cs	Sun Oct 04 09:47:16 2009 +0000
@@ -64,7 +64,7 @@
 		{
 			commandStack.Clear();
 			listMax = -1;
-			listPos = -1;
+			listPos = -1;
 			cleanPos = -1;
 			DoCommandStackUpdated();
 		}
--- a/IBBoard.csproj	Tue Sep 29 19:19:44 2009 +0000
+++ b/IBBoard.csproj	Sun Oct 04 09:47:16 2009 +0000
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <ProjectType>Local</ProjectType>
--- a/Xml/XmlTools.cs	Tue Sep 29 19:19:44 2009 +0000
+++ b/Xml/XmlTools.cs	Sun Oct 04 09:47:16 2009 +0000
@@ -4,6 +4,7 @@
 // 
 
 using System;
+using System.Globalization;
 using System.Text.RegularExpressions;
 using System.Xml;
 
@@ -16,7 +17,8 @@
 	{
 		private static Regex idRegex;
 		private static Regex multiUnderscoreRegex;
-		
+		private static NumberFormatInfo doubleFormat;
+
 		/// <summary>
 		/// Gets the value of an attribute of an element as a boolean. Throws a FormatException if the attribute is not a boolean.
 		/// </summary>
@@ -90,7 +92,7 @@
 			{
 				try
 				{
-					return double.Parse(attribValue);
+					return double.Parse(attribValue, GetNumberFormatInfo());
 				}
 				catch(FormatException)
 				{
@@ -100,7 +102,17 @@
 			
 			return doubleVal;
 		}
-		
+
+		private static NumberFormatInfo GetNumberFormatInfo()
+		{
+			if (doubleFormat == null)
+			{
+				doubleFormat = NumberFormatInfo.InvariantInfo;
+			}
+
+			return doubleFormat;
+		}
+
 		private static Regex GetIdRegex()
 		{
 			if (idRegex == null)