Migrating Orchard From Autofac

Jun 14, 2011 at 12:31 PM

Hi, how do i convert the following from Autofac to Unity (where _context is of type IComponentContext):

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

The code above is taken from Orchard and and i'm trying to understand the code fully before i'm going to make the plunge into using it. Ideally i'd like to remove the dependency on Autofac or Untiy altogether. If there's a way this can be done using the Common Service Locator that would also be appreciate. Usually i'd try something like:

 

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

 

 

 

 

But i can't see how to handle the TypedParameter stuff.

I'd really appreciate it if someone could help.

Jun 15, 2011 at 5:57 PM

Given that as mentioned, you would want this be done using Common Service Locator, I would think posting this inquiry from there (http://commonservicelocator.codeplex.com/) may help you get better answer :o) HTH.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com

Jun 15, 2011 at 9:23 PM
AvanadeSupport wrote:

Given that as mentioned, you would want this be done using Common Service Locator, I would think posting this inquiry from there (http://commonservicelocator.codeplex.com/) may help you get better answer :o) HTH.

Gino Terrado
Global Technologies and Solutions
Avanade, Inc.
entlib.support@avanade.com


No, no it won't. The Common Service Locator is just an interface for resolves. It doesn't say a darn thing about configuration, for some very good reasons, and this issue is all about configuration.

I can't help because I have no idea what autofac's TypedParameters are or what they do. Some more details on their functionality would help in solving the issue.

 

Jun 22, 2011 at 3:04 PM

Hi, apparently it's not possible with the common service locator so i guess i'll have to stick with Autofac for now.