Skip to content

Commit

Permalink
Fixed double parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
leMicin committed Dec 31, 2020
1 parent 7233d97 commit 934ff7d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using Sidekick.Domain.Game.Items.Models;
Expand Down Expand Up @@ -69,7 +70,7 @@ public double GetDouble(Regex regex, string input)
{
var match = regex.Match(input);

if (match.Success && double.TryParse(match.Groups[1].Value.Replace(",", "."), out var result))
if (match.Success && double.TryParse(match.Groups[1].Value.Replace(",", "."), NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
{
return result;
}
Expand All @@ -91,8 +92,8 @@ public double GetDps(Regex regex, string input, double attacksPerSecond)
.Select(x => x.Value.Split("-"))
.Sum(split =>
{
if (double.TryParse(split[0], out var minValue)
&& double.TryParse(split[1], out var maxValue))
if (double.TryParse(split[0], NumberStyles.Any, CultureInfo.InvariantCulture, out var minValue)
&& double.TryParse(split[1], NumberStyles.Any, CultureInfo.InvariantCulture, out var maxValue))
{
return (minValue + maxValue) / 2d;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
Expand Down Expand Up @@ -242,7 +243,7 @@ private void ParseMod(List<Modifier> mods, string text, ModifierPattern data, Ma
{
for (var index = 1; index < result.Groups.Count; index++)
{
if (double.TryParse(result.Groups[index].Value, out var parsedValue))
if (double.TryParse(result.Groups[index].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out var parsedValue))
{
var modifierText = modifier.Text;
if (negative)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var stringValue = value.ToString();
if (double.TryParse(stringValue, out var doubleValue))
if (double.TryParse(stringValue, NumberStyles.Any, CultureInfo.InvariantCulture, out var doubleValue))
{
return doubleValue;
}
Expand Down

0 comments on commit 934ff7d

Please sign in to comment.