Дизайн - Где объекты должны быть зарегистрированы при использовании [закрытого] Виндзора

Ну, свободный и не бесплатно, я использую .NET WebSuperGoo ABCpdf компонент, что я просто люблю его!

не бесплатно , потому что необходимо заплатить за него.

для свободного , потому что, даже если необходимо заплатить, у них есть пробная версия и Вы можете запрашивать бесплатную лицензию , если Вы не возражаете, это, на Вашем шоу сайта "Этот сайт использует компонент.NET WebSuperGoo ABCpdf" со ссылкой на их веб-сайт.

я сделал это, и я получил бесплатную лицензию (версия 5 в то время) так, я могу сказать, что это работает (даже если веб-сайт больше не онлайн) - я все еще имею и использую компонент ~:)

А замечательная вещь, которую я люблю с этим, состоит в том, что можно сделать все, что Вы можете вещь прочь с этим, создать формы PDF и динамично заполнить их и отправить пользователю почтой или иметь их, чтобы загрузить его, создать PDF с нуля, преобразовать страницы HTML в PDF, и т.д. и т.д. и т.д., прочитайте документацию, это - замечательный компонент.

48
задан adam0101 15 March 2011 в 19:22
поделиться

1 ответ

In general, all components in an application should be composed as late as possible, because that ensures maximum modularity, and that modules are as loosely coupled as possible.

In practice, this means that you should configure the container at the root of your application.

  • In a desktop app, that would be in the Main method (or very close to it)
  • In an ASP.NET (including MVC) application, that would be in Global.asax
  • In WCF, that would be in a ServiceHostFactory
  • etc.

The container is simply the engine that composes modules into a working application. In principle, you could write the code by hand (this is called Poor Man's DI), but it is just so much easier to use a DI Container like Windsor.

Such a Composition Root will ideally be the only piece of code in the application's root, making the application a so-called Humble Executable (a term from the excellent xUnit Test Patterns) that doesn't need unit testing in itself.

Your tests should not need the container at all, as your objects and modules should be composable, and you can directly supply Test Doubles to them from the unit tests. It is best if you can design all of your modules to be container-agnostic.

Also specifically in Windsor you should encapsulate your component registration logic within installers (types implementing IWindsorInstaller) See the documentation for more details

76
ответ дан 26 November 2019 в 18:41
поделиться
Другие вопросы по тегам:

Похожие вопросы: