// This Source Code is partially based on the source code provided by the .NET Foundation. // ReSharper disable once CheckNamespace namespace WPFluent.Controls; /// /// Base nubmer formatter that uses default format specifier and that represents the culture /// used by the current thread. /// public class ValidateNumberFormatter : INumberFormatter, INumberParser { private static CultureInfo GetCurrentCultureConverter() { return CultureInfo.CurrentCulture; } private static string GetFormatSpecifier() { return "G"; } /// public string FormatDouble(double? value) { return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? string.Empty; } /// public string FormatInt(int? value) { return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? string.Empty; } /// public string FormatUInt(uint? value) { return value?.ToString(GetFormatSpecifier(), GetCurrentCultureConverter()) ?? string.Empty; } /// public double? ParseDouble(string value) { return double.TryParse(value, out var d) ? d : null; } /// public int? ParseInt(string value) { return int.TryParse(value, out var i) ? i : null; } /// public uint? ParseUInt(string value) { return uint.TryParse(value, out var ui) ? ui : null; } }