I was going through some old code of mine and came across a hybrid IValueConverter
/ MarkupExtension
class. It got me wondering if the IServiceProvider
in the ProvideValue
method was actually useful, and how it would be useful?
I see that IServiceProvider
only has one method: GetService
, which must be cast to the proper service type. I also looked at the MarkupExtension.ProvideValue MSDN page and it lists different types of services. I guess, I'm just wondering if any of those services are useful or should I just leave my method as it is?
Current Method:
public Object ProvideValue(IServiceProvider serviceProvider)
{
return new MyConverter();
}
Basically, should I do the following:
public Object ProvideValue(IServiceProvider serviceProvider)
{
var provider = serviceProvider as SomeType;
if (provider == null) return new MyConverter();
//Do something with the provider here?
}