Debugging an elusive Mono bug in Double.Parse

This commit is contained in:
Rick Falkvinge
2014-12-28 13:48:02 +01:00
parent 19f73cca0b
commit 6ef1239b41
2 changed files with 6 additions and 2 deletions
@@ -23,11 +23,11 @@ namespace Swarmops.Frontend.Controls.v5.Financial
double outParse = 0.0;
string contents = Input.Text;
if (Double.TryParse (contents, NumberStyles.Currency, CultureInfo.CurrentCulture, out outParse))
if (Double.TryParse (contents, NumberStyles.AllowThousands | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint, CultureInfo.CurrentCulture, out outParse))
{
return outParse;
}
if (Double.TryParse (contents, NumberStyles.Currency, CultureInfo.InvariantCulture, out outParse))
if (Double.TryParse(contents, NumberStyles.AllowThousands | NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out outParse))
{
return outParse;
}
@@ -62,6 +62,10 @@ namespace Swarmops.Frontend.Pages.v5.Financial
{
// The data has been validated client-side already. We'll throw unfriendly exceptions if invalid data is passed here.
// MONO BUG: Need to re-set the current culture for parsing to work properly.
AuthenticationData authData = CommonV5.GetAuthenticationDataAndCulture (HttpContext.Current);
double amount = this.TextAmount.Value;
Int64 amountCents = (Int64) amount*100;