DeviceManager/DeviceRepairAndOptimization/CustomFormatProvider/StatusFormatter.cs
2024-07-02 00:52:48 +08:00

50 lines
1.2 KiB
C#

using System;
namespace DeviceRepairAndOptimization.CustomFormatProvider
{
public class StatusFormatter : IFormatProvider, ICustomFormatter
{
public object GetFormat(Type formatType)
{
if (formatType == typeof(ICustomFormatter))
{
return this;
}
return null;
}
public string Format(string format, object arg, IFormatProvider formatProvider)
{
string value = string.Empty;
switch (format.ToLower())
{
case "tag":
value = tagFormat(arg);
break;
default:
break;
}
return value;
}
string tagFormat(object arg)
{
string value = string.Empty;
switch (arg?.ToString() ?? "")
{
case "N":
value = "已提交";
break;
case "C":
value = "已完成";
break;
default:
break;
}
return value;
}
}
}