开发者

Windsor Registration Child Container Visibility

I have some (sort of) Singletons 开发者_开发技巧which exist in three context:

  1. Per AppDomain

  2. Per HttpApplication

  3. Per Web Request

Right now, I'm creating a child container per HttpApplication and another child per Web Request. This is necessary because some components SHOULD actually share singleton instances across the three layers. For security and other reasons, there are certain registrations that SHOULD NOT actually share the singleton (one per container).

Does anyone have a suggestion as to how to implement this or how I can limit the visibility of registrations within a container hierarchy?

Thanks.


As Stuart says, lifestyles are the correct extension point to do this. Child containers are not necessary. Per web request comes out of the box in Windsor, and IIRC the Singleton lifestyle (the default one) works per appdomain. The per-HttpApplication lifestyle is implemented in the Castle.Windsor.Lifestyles contrib project.


Have you tried using lifestyles to solve this problem? A combination of the Singleton and PerWebRequest lifestyles may satisfy your requirements, without requiring child containers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜