using System.Numerics; using GFramework.Core.Abstractions.Utility.Numeric; namespace GFramework.Core.Utility.Numeric; /// /// 数值显示静态入口。 /// public static class NumericDisplay { private static readonly NumericDisplayFormatter DefaultFormatter = new(); /// /// 将数值格式化为展示字符串。 /// public static string Format(T value, NumericFormatOptions? options = null) where T : INumber { return DefaultFormatter.Format(value, options); } /// /// 将运行时数值对象格式化为展示字符串。 /// public static string Format(object value, NumericFormatOptions? options = null) { return DefaultFormatter.Format(value, options); } /// /// 使用默认紧凑风格格式化数值。 /// public static string FormatCompact( T value, int maxDecimalPlaces = 1, IFormatProvider? formatProvider = null) where T : INumber { return Format(value, new NumericFormatOptions { MaxDecimalPlaces = maxDecimalPlaces, FormatProvider = formatProvider }); } /// /// 使用默认紧凑风格格式化运行时数值对象。 /// public static string FormatCompact( object value, int maxDecimalPlaces = 1, IFormatProvider? formatProvider = null) { return Format(value, new NumericFormatOptions { MaxDecimalPlaces = maxDecimalPlaces, FormatProvider = formatProvider }); } }