} // ctor object IFormatProvider.GetFormat(Type formatType) { if (formatType == typeof(ICustomFormatter)) { return(this); } else { return(FormatProvider.GetFormat(formatType)); } } // func IFormatProvider.GetFormat
private string FormatValue() { string result = null; if (FormatProvider?.GetFormat(Value?.GetType()) is ICustomFormatter formatter) { result = formatter.Format(Format, Value, CultureInfo.CurrentCulture); } if (result == null && Value is IFormattable formattable) { result = formattable.ToString(Format, FormatProvider); } return(result ?? Value?.ToString() ?? string.Empty); }