ContactManager sample questions

Topics: Web Api
Oct 31, 2010 at 9:33 PM

Hi,

I have some questions regarding the sample code:

1. I'm looking at ContactManager.ContactsResource and wonder how can I make the sample resolve ContactsResource against an IoC container?

2. Same question regarding Processors - I would want a Processor with an NHibernate ISession dependency (and possibly others) built by an IoC container.

3. I assume processor's lifetime is per call?

so far it looks nice but IoC support/sample is much appreciated.

 

Thanks.

Robert.

Coordinator
Oct 31, 2010 at 11:10 PM

Hi Robert

1. We don't have any in-the-box IoC solution yet for injecting dependencies into the constructor. We have an instance provider extensibility point that can be used for an IoC which we are going to explore. CommonServiceFactory on codeplex uses this for plugging in an IoC.

2. Processors however can easily be built up by a container as you construct the processor yourself. To handle an NHib session what you would do is have a special processor that creates an NHib session (from a session factory) and then provides it as one of it's outputs. This allows other processors to take the session as an input or the operation to access the session through one of it's parameters.

3. Processors are actually designed to be stateless with regards to the request. The same processor instance is reused across all requests. The execute method is passed all the state that the processor needs to do it's work. The processor can still have some state, but it should not be related to the request.

I'll plan a blog post on processors to describe this in more detail. I will also work on getting our IoC prototype in place.

If supporting IoC containers is important, can you add a work item so others can vote?

Thanks

Glenn

 

 

Nov 1, 2010 at 10:21 AM

Hi Glenn,

Thanks for your answers. I added a workitem for IoC support (http://wcf.codeplex.com/workitem/3).

Robert.