Skip to content

Commit e48a4b2

Browse files
committed
DecimalStringParser
1 parent 3212872 commit e48a4b2

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

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

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,25 @@ public bool TryParse(string text, out int value) =>
3838
}
3939

4040

41+
42+
internal sealed class DecimalStringParser : IStringParser<decimal>
43+
{
44+
private readonly IFormatProvider _formatProvider;
45+
46+
public DecimalStringParser(IFormatProvider formatProvider)
47+
{
48+
_formatProvider = formatProvider;
49+
}
50+
51+
public bool TryParse(string text, out decimal value) =>
52+
decimal.TryParse(
53+
text,
54+
NumberStyles.Number,
55+
_formatProvider,
56+
out value);
57+
}
58+
59+
60+
61+
4162
}

0 commit comments

Comments
 (0)