Esempio n. 1
0
        }         // ctor

        object IFormatProvider.GetFormat(Type formatType)
        {
            if (formatType == typeof(ICustomFormatter))
            {
                return(this);
            }
            else
            {
                return(FormatProvider.GetFormat(formatType));
            }
        }         // func IFormatProvider.GetFormat
Esempio n. 2
0
        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);
        }