Debugging an elusive Mono bug in Double.Parse
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user