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