mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 17:31:42 +08:00
6e74917b43
* feat: add page-header components * feat: add page-header components * feat: add page-header components * docs: some bugs of PageHeader * refactor: clean code Co-authored-by: ElderJames <shunjiey@hotmail.com>
49 lines
1.6 KiB
C#
49 lines
1.6 KiB
C#
using System;
|
|
using System.Linq;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public partial class Statistic<TValue> : StatisticComponentBase<TValue>
|
|
{
|
|
[Parameter] public string DecimalSeparator { get; set; } = ".";
|
|
|
|
[Parameter] public string GroupSeparator { get; set; } = ",";
|
|
|
|
[Parameter] public int Precision { get; set; } = -1;
|
|
|
|
private string IntegerPart
|
|
{
|
|
get
|
|
{
|
|
if (typeof(TValue).IsAssignableFrom(typeof(string))) return Value.ToString();
|
|
else return Convert.ToDecimal(Value).ToString($"###{GroupSeparator}###");
|
|
}
|
|
}
|
|
|
|
private string FractionalPart
|
|
{
|
|
get
|
|
{
|
|
if (typeof(TValue).IsAssignableFrom(typeof(string)))
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
string tem;
|
|
if (Precision > 0)
|
|
tem = Math.Round(Convert.ToDecimal(Value), Precision).ToString().Contains('.')
|
|
? Math.Round(Convert.ToDecimal(Value), Precision).ToString().Split('.').Last().PadRight(Precision, '0')
|
|
: string.Empty.PadRight(Precision, '0');
|
|
else if (Precision < 0)
|
|
tem = Value.ToString().Contains('.') ? Value.ToString().Split('.').Last() : null;
|
|
else
|
|
tem = null;
|
|
return string.IsNullOrEmpty(tem) ? null : DecimalSeparator + tem;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|