using System; namespace TsSFCDevice.Control.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; } } }