Skip to content

Commit 0bcdaab

Browse files
committed
DoubleStringParser
1 parent e48a4b2 commit 0bcdaab

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

  • src/IGLib.Core/Console/Validation/Implementations/StringParsing

src/IGLib.Core/Console/Validation/Implementations/StringParsing/Parsers.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ public bool TryParse(string text, out decimal value) =>
5757
}
5858

5959

60+
internal sealed class DoubleStringParser : IStringParser<double>
61+
{
62+
private readonly IFormatProvider _formatProvider;
63+
64+
public DoubleStringParser(IFormatProvider formatProvider)
65+
{
66+
_formatProvider = formatProvider;
67+
}
68+
69+
public bool TryParse(string text, out double value) =>
70+
double.TryParse(
71+
text,
72+
NumberStyles.Float | NumberStyles.AllowThousands,
73+
_formatProvider,
74+
out value);
75+
}
6076

6177

6278
}

0 commit comments

Comments
 (0)