Specific PerThread Resolve

May 28, 2008 at 5:11 PM
Let's say I have a service application  built around a pipeline kind of framework (e.g. IIS, or WCF), one of my business logic classes called PersonService (transisent) has two constructor arguments IDataProvider and IUserEntity.

IDataProvider is satisified easily via a type mapping in the config to a concrete type of say MyProduct.DataProvider
IUserEntity however is initialised further back in the pipeline, so its varies perthread..

I mean I could in my PersonService grab it from HttpContext (IIS) or OperationContext (WCF) but this makes unit testing more difficult, sincce I would be able to initialize personservice normally or have dependencies satisifed by static entry in unit testing config.

Essentially I need a sort of err... container per thread right? but some at application level and some at thread level.. overhead? yikes

Any thoughts?
May 28, 2008 at 5:27 PM
Thinking more all I really need is the following

container.ResolveButUseArgumentsAsPreferredWherePossible<IPersonService>(HttpContext.Current["User"]);