using System; namespace ScreenConnect; public class FormatterBase : IFormatProvider, ICustomFormatter { object IFormatProvider.GetFormat(Type formatType) { if ((object)formatType != typeof(ICustomFormatter)) { return null; } return this; } string ICustomFormatter.Format(string format, object arg, IFormatProvider formatProvider) { return Format(format, arg, formatProvider); } protected virtual string Format(string format, object arg, IFormatProvider formatProvider) { if (!(arg is IFormattable formattable)) { if (arg == null) { return string.Empty; } return arg.ToString(); } return formattable.ToString(format, this); } }