Castle.Windsor lifestyle depending on context?

后端 未结 5 950
孤街浪徒
孤街浪徒 2020-12-29 04:44

I have a web application where many components are registered using .LifestylePerWebRequest(), now I\'ve decided to implement Quartz.NET, a .NE

5条回答
  •  长发绾君心
    2020-12-29 05:19

    You should use Hybrid Lifestyle from castleprojectcontrib.

    An hybrid lifestyle is one that actually blends two underlying lifestyles: a main lifestyle and a secondary lifestyle. The hybrid lifestyle first tries to use the main lifestyle; if it's unavailable for some reason, it uses the secondary lifestyle. This is commonly used with PerWebRequest as the main lifestyle: if the HTTP context is available, it's used as the scope for the component instance; otherwise the secondary lifestyle is used.

提交回复
热议问题