Sicherung
This commit is contained in:
26
Config.Net/TypeParsers/DecimalParser.cs
Normal file
26
Config.Net/TypeParsers/DecimalParser.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
||||
namespace Config.Net.TypeParsers
|
||||
{
|
||||
class DecimalParser : ITypeParser
|
||||
{
|
||||
public IEnumerable<Type> SupportedTypes => new[] { typeof(decimal) };
|
||||
|
||||
public bool TryParse(string? value, Type t, out object? result)
|
||||
{
|
||||
decimal dr;
|
||||
bool parsed = decimal.TryParse(value, NumberStyles.Float, TypeParserSettings.DefaultCulture, out dr);
|
||||
result = dr;
|
||||
return parsed;
|
||||
|
||||
}
|
||||
|
||||
public string? ToRawString(object? value)
|
||||
{
|
||||
return ((decimal?)value)?.ToString(TypeParserSettings.DefaultNumericFormat, TypeParserSettings.DefaultCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user