I am working on an ASP MVC 3 app and I'm writing a custom html helper. It's nothing special or hugely complex, but it will need an instance of an interface from structure map. I know I can simply call into structuremaps' object factory from inside the method, but since the rest of the app uses IoC rather than service location I'd like to keep it that way.
Is there a way to inject interfaces into extension methods from inside and asp net mvc app?
UPDATE
An example of what I'm doing might help:
public static class ShowUrl
{
public static string ForShow(this UrlHelper url, int showId)
{
var service = ObjectFactory.GetInstance<IPerformanceService>();
var showName = service.GetPerformanceTitle(showId);
return url.Action(MVC.Performance.Details(showId, showName.ToFriendlyUrl()));
}
}
Which is used like this:
<a href='<%= Url.ForShow(1)%>'>
Essentially I am trying to build a URL with a slug from an entity id. Maybe I'm just going about this in a really daft way.