Difference between IWindsorInstaller and AbstractFacility in Castle

≡放荡痞女 提交于 2019-11-30 12:38:55

Dan,

the difference is the following:

  • 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.

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.

Hope that makes the distinction clearer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!