开发者

using same implementation with different lifestyles Windsor

I have a class like this:

public FooRepo : IFooRepo
{
   public FooRepo(IDbContextF开发者_C百科actory factory)
   {
      context = factory.GetContext();
   }
}

In my app I register everything with LifeStyle.PerWebRequest, but now I need to call one Method which uses this IFooRepo like this (because it's gonna take about an hour):

{
 ...
    ThreadPool.QueueUserWorkItem(s => RequestReport(number));
 ...
}
private void RequestReport(int number)
{
// IFooRepo needed here
}

the problem is that I need this IFooRepo with PerWebRequest lifestyle most of the time, and I needed here in the thread also to stay alive, also it has a dependency IDbContextFactory which I don't know if I need to register it also in a different way


well then register your FooRepo twice and setup service override for whoever uses in on the ThreadPool to use the other component. Easy.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜