This project is read-only.

Newbie Q: DependencyResolver.current, ILifetimeScope, IWorkContextScope, IContainer, IComponentContext

Topics: Writing modules
Mar 28, 2013 at 6:27 AM
Which one of the objects in the subject title am I supposed to call the Resolve method on to create an instance of my DI class???

I know one way is just pass the object in the constructor and Orchard will create the instance but for my case the DI object is imbedded way down in the call structure and the parent doesn't use injection.
Mar 29, 2013 at 5:40 PM
I don't think Orchard initializes DependencyResolver, but I'm not sure, so you could try that one.
The others need to be injected or resolved somehow since they are mere interfaces, so I'm not sure how you intend to use them with having a resolver already or inject them.
If your code can use HttpContext, you could resolve instances like this:
var workContext = HttpContext.Current.Request.RequestContext.GetWorkContext();
var service = workContext.Resolve<IMyService>();
But, if you ask me, not being able to inject dependencies has a bit of a design smell, so I would carefully look at your current design and see if it needs refactoring.