Consider the following code:
public class InboxMenuItemDynamicProvider : DynamicNodeProviderBase
{
private IMyService _myService { get; set; }
public InboxMenuItemDynamicProvider(IActionService actionService)
{
_myService = myService;
}
public override IEnumerable<DynamicNode> GetDynamicNodeCollection()
{
// use _myService here....e.g. db access
}
}
}
How do I go about injecting a service dependency into a Mvc Sitemap DynamicNodeProvider using StructureMap and MVC3? I'm using the MVC3 dependency resolver.
However, on running the app, I get a 'no default constructor' error. I need to somehow inject service dependencies into the provider, but I'm at a total loss as to where/how I can inject them. I don't even know if its possible as Mvc Site Map might be outside of the depency resolver.
See this link: http://mvcsitemap.codeplex.com/discussions/263971
I think you could just use:
private IMyService _myService
{
get
{
return DependencyResolver.Current.GetService<IMyService>();
}
}
and do nothing specific in your constructor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With