Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.3.0
-
All phone configured to use the FR-FR locale (the emulator included)
Description
There is a bug in the Accelerometer.cs file of the WP7GalClassLib library in the way to formats the current coordinates into JSON format.
Here is the kind of output produced on a FR-FR locale (and on any locale using the coma character as the separated character for numerics) :
"
{\"x\":0,00472,\"y\":-0,19879,\"z\":-0,98115}" instead of "
{\"x\":0.00472,\"y\":-0.19879,\"z\":-0.98115}" for EN-US.
The JSON.Parse() instruction then raises a Syntax Error exception later on due to the bad formatting of the JSON string.
To fix the bug, the code of the GetCurrentAccelerationFormatted() method needs to be changed by this one:
private string GetCurrentAccelerationFormatted()
{
string resultCoordinates = String.Format("\"x\":
,\"y\":
{1},\"z\":
{2}",
accelerometer.CurrentValue.Acceleration.X.ToString("0.00000", CultureInfo.InvariantCulture),
accelerometer.CurrentValue.Acceleration.Y.ToString("0.00000", CultureInfo.InvariantCulture),
accelerometer.CurrentValue.Acceleration.Z.ToString("0.00000", CultureInfo.InvariantCulture));
resultCoordinates = "
";
return resultCoordinates;
}
It adds the usage of CultueInfo.InvariantCulture available in the System.Globalization namespace to always have the same formatting whatever the locale is.