We're looking to implement custom formatters, as per usual, best to use interfaces from Microsoft, so I find ICustomFormatter.
http://msdn.microsoft.com/en-us/library/system.icustomformatter.format(v=vs.110).aspx
However the signature for the interface provides this:
public string Format(string format, object arg, IFormatProvider formatProvider)
{
}
What would I even use formatProvider for? I've yet to see good examples of why you're concerned about what formatProvider has loaded this ICustomFormatter.
The only example I've found is something like this:
http://www.codeproject.com/Articles/6533/Custom-String-Formatting-in-NET
if (formatProvider is NumberFormatInfo)
if (((NumberFormatInfo)formatProvider).UseDiacritic)
c = diacritic;
But this just looks like awful design (take an interface and then strongly coupling it).
Am I missing some special use-case?
The IFormatProvider is there to provide culture-specific and global formatting information to your custom formatter. Of course, depending on what your custom formatter is doing, you might not need any of this information, but if you were formatting currency or floating point numbers or dates, for example, then you might well want it.