在城堡IWindsorInstaller和AbstractFacility的区别 [英] Difference between IWindsorInstaller and AbstractFacility in Castle

查看:228
本文介绍了在城堡IWindsorInstaller和AbstractFacility的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直用的设施登记自己的组件,但已经注意到了IWindsorInstaller。

I've always been using facilities to register my components but noticed the IWindsorInstaller.

这两个类似于我,我想知道的区别是两者,哪些应该使用的一个之间有什么在哪里。

It both look similar to me and I would like to know what the difference is between both and which one should be used where.

推荐答案

的差异是:

  • 安装是为了封装登记的离散单位。换句话说,你用安装人员的注册容器中的应用程序组件的。 有帮手的,像配置类,或 FromAssembly ,你可以用它来既可以使用配置文件类,或自动发现您的安装和运行它们都在一个走,因为在大多数的应用程序,你将有几个人。
  • 设施是为了增强该出的容器的盒功能。所以,你必须(使用标准设备为例)像 TypedFactoryFacility 这增加了能够自动创建的工厂透明地从容器中拉出组件。您有 StartableFacility 它允许组件的启动/停止的,您无需显式地担心。您还可以集成工具像NHibernate的,或WCF,还是单轨,或ASP.NET MVC的事情,让温莎意识到它与让您的工作更容易其他框架的某些方面。在能力方面的设施都可以有自己的配置。此外,还有没有帮手批量添加设施,在大多数的应用程序,你只需要几个。
  • installers are meant to encapsulate discrete units of registration. In other words you use installers to register application components in the container. There are helpers for that like Configuration class, or FromAssembly class that you can use to either use configuration file, or to autodiscover your installers and run them all in one go because in most apps you will have several of them.
  • facilities are meant to augment the out of the box capabilities of the container. So you have (using standard facilities as examples) things like TypedFactoryFacility which adds ability to auto create factories to transparently pull components from the container. You have StartableFacility which allows components to be started/stopped without you having to explicitly worry about it. You also have integration facilities for things like NHibernate, or WCF, or Monorail, or ASP.NET MVC that make Windsor aware of certain aspects of other frameworks it works with so that your work is easier. In terms of capabilities facilities can have their own configuration. There also is no helpers to batch add facilities as in most apps you'll only need a few.

他们都可以注册,但里面的主要区别是 - 安装注册无论您的应用需求(包括增加设施)。在另一方面寄存器设施各取所需,以做好本职工作。

Both of them can register stuff, but the main difference is - installers register whatever your application needs (including adding facilities). Facilities on the other hand register what they need in order to do their job.

这通常意味着设备注册扩展到容器中,如自定义解析器,ComponentModel建设贡献者或拦截器 - 事情的定义都知道容器

That usually means that facilities register extensions to the container like custom resolvers, ComponentModel construction contributors or interceptors - things which by definition are aware of the container.

安装寄存器,它最好不认识的容器的所有应用级组件。

Installers register application level components which best have no knowledge of the container at all.

希望这是区分更清晰。

这篇关于在城堡IWindsorInstaller和AbstractFacility的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆