English 中文(简体)
2. 自动选择每读或每读活期范围
原标题:Automatically Select Per-Thread or Per-Request Lifetime Scopes
  • 时间:2011-10-04 21:39:00
  •  标签:
  • autofac

我正在开发一个图书馆,向我公司内部分发,并用各种应用程序消耗。 这一图书馆必须成为平台,因为它可能部署在网络环境中,甚至可以在一个青少年的镜头上部署。 我愿根据使用这一框架的适用范围,对物体进行永久或永久登记。 在结构分配中,我可以使用混合寿命这样做。 基本上,如果存在HttpContext,则该物体的范围将扩大到该物体,否则将按每读即可使用当地供应商。 分配的图书馆或耗用应用程序不需要额外配置。 是否可能使用自动法? 鉴于我们开发商的技能水平差异很大,我们的目标是尽量减少/消除任何消费者的专门配置。

我的理解是,登记可以是使用假肢寿命的假肢,但随后需要消费申请才能消耗ASP.NET/WCF/MVC的集成双体,以约束假肢。 《Http请求书》的范围登记。 或者,就近距离范围而言,消费法需要负责创建

任何建议?

问题回答

It s easy to implement own lifetime manager that will check if HttpContext.Current != null and then delegate to one of the existing managers.

不过,我建议,每项申请都与适当的管理人员本身挂钩。 一个实例是,可能不存在HttpContext的单位测试情景,因为HttpContext可能 mo笑你为了测试特定目的人工控制终身。





相关问题
Registering Collections in Autofac 2.1.10 RC

I am upgrading code from Autofac 1.4 to 2.1.10 Release Candidate. My module previously performed registration like this: builder.RegisterCollection<IExceptionHandler>() .As<...

How to carry out custom initialisation with autofac

I m adding autofac to an existing project and some of the service implementations require their Initialize method to be called and passed configuration information. Currently I m using the code: ...

Autofac doesn t like MVC Source

I added the ASP.NET MVC 2 RC2 source code to my solution (using these instructions: http://blog.stevensanderson.com/2009/02/03/using-the-aspnet-mvc-source-code-to-debug-your-app/), but now it won t ...

IOC/Autofac container

I am currently using Autofac, but am open to commentary regarding other IOC containers as well. I would prefer a solution using Autofac if possible. I am also somewhat new to IOC so I may be grossly ...

Dependency Injection for Presenter

I have a Presenter that takes a Service and a View Contract as parameters in its constructor: public FooPresenter : IFooPresenter { private IFooView view; private readonly IFooService service;...

热门标签