Autofac for Shared Services Locator (TypedParameter issue)

How do I change the following from Autofac to use the Common Service Locator (where _context is of type IComponentContext):

var query = _context.Resolve<IContentQuery>(TypedParameter.From<IContentManager>(this));

The code above is taken from Orchard, and I'm trying to remove the Autofac dependency. Normally I would try something like:

var query = ServiceLocator.Current.GetInstance<IContentQuery>();

However, this returns null, and I don’t see how to handle the TypedParameter stuff, since I don’t understand what it does.

I would really appreciate it if someone could help. Thanks

+3
source share
1 answer

A TypedParameterprovides additional value to the constructor of the resolvable component. In this case, the base ContextQuerywill take a type parameter IContentManagerwith the passed value this.

Common Service Locator , , , IoC.

, .

+3

All Articles