Sunday, December 20, 2009
Thursday, December 3, 2009
Thursday, November 19, 2009
Injection in Unity
Unity выполняет регистрацию соответствия типов и экземпляров объектов.
Кроме этого, он может самостоятельно выполнять создание этих объектов по запросу.
Unity основан на ObjectBuilder, более простом и, на данный момент, устаревшем контейнере.
Injection может быть трех типов:
- Construction injection
- Property injection
- Method call injection

- Constructor injection. This type of injection occurs automatically. When you create an instance of an object using the Unity container, it will automatically detect the constructor with the largest number of parameters and execute this, generating instances of each object defined in the constructor parameters. It resolves each parameter type through the container, applying any registrations or mappings for that type. If you want to specify a particular constructor for Unity to use, you can add the InjectionConstructor attribute to that constructor in the target class.
- Property (setter) injection. This type of injection is optional. You can add the Dependency attribute to any property declarations that you want Unity to resolve through the container. Unity will resolve that property type and set the value of the property to an instance of the resolved type.
- Method call injection. This type of injection is also optional. You can add the InjectionMethod attribute to any method declarations where you want Unity to resolve the method parameters through the container. Unity will resolve each parameter type and set the value of that parameter to an instance of the resolved type, and then it will execute the method. Method call injection is useful if you need to execute some type of initialization method within the target object.
Если в конфигурации не указан тип, который нужно разрешить во время выполнения, тогда Unity просто выполняет инстанцирование этого объекта, просматривая его конструктор. Если конструктор имеет параметры, аналогично, делается попытка найти эти параметры в контейнере. Есть опасность возникновения циклических зависимостей, когда происходит injection двух типов, каждый из которых в качестве параметров конструктора указывает на второй объект.
Monday, November 16, 2009
Интересные статьи
Использование измененного LZW алгоритма,
построение N- грамматик для извлечения шаблонов текста из текста.
Символьное дифференцирование
Neural Networks on C#
Designing And Implementing A Neural Network Library For Handwriting Detection, Image Analysis etc.
Friday, November 13, 2009
MVP и Unity
Источник: http://gandjustas.blogspot.com/2009/06/mvp-unity.html
MVP – Model View Presenter – паттерн организации PL (presentation layer – уровень представления).
MVP применяется при создании десктопных интерфейсов. Выделяют три комопнента: есть модель – группа классов, которые отдают данные или получают команды, представление – форма обладающая состоянием и некоторым поведением. Презентер создают для отделения бизнес-логики от деталей GUI-фреймворка. В отличие от MVC в MVP представление определяет презентер, а не наоборот.
MVP обычно строится вокруг существующих GUI-фреймворков. На практике существуют две принципиально различные различные реализации паттерна – Supervising Controller и Passive View.
В первом случае логика помещается в обработчики событий button_click, а сами обработчики помещаются в отдельный класс. Для полной изоляции презентера от деталей представления надо писать достаточно много врапперов\адаптеров.
Во втором случае создается пара интерфейсов для общения между представлением и презентером. При совершении какого-либо действия представление напрямую обращается к презентеру, тот выполняет некоторый код и вызывает установку свойств представления. Passive View способствует максимальному перемещению кода в в презентер, что облегчает тестирование.
Реализация: Presenter содержит ссылки на View и сервис. Он использует сервисы, обновляет данные, отправляет команды во View. View содержит ссылку на Presenter. При обработке клика на кнопке он отправляет команды в Presenter.
Wednesday, November 4, 2009
Prism, Composite Application Guidance, CompositeWPF: общие положения
Скачать:
- ссылка
- Composite Application Guidance for WPF and Silverlight
- WPF Contrib (extensions and more samples for Prism)
- Project White (automated UI testing framework for WinForms, WPF, etc.)
compositewpf.codeplex.com
unity.codeplex.com
www.codeplex.com/unity
compositewpfcontrib.codeplex.com/wikipage?title=WPFQuickstartRegeneratedWithCAL
Блог:
http://weblogs.asp.net/bsimser/archive/tags/WPF/default.aspx
Скринкасты:
channel9.msdn.com/posts/akMSFT/What-is-Prism-v2
www.pnpguidance.net/Post/PrismWebcastsScreencastsCreateApplicationUsingPrism.aspx
Блог, посвященный Enterprise Patterns:
www.pnpguidance.net/Default.aspx
blogs.msdn.com/bobbrum/default.aspx
www.tanguay.info/web/index.php?pg=books&id=23
Статья в MSDN:
Inject Some Life into Your Applications—Getting to Know the Unity Application Block
You Can Depend On Patterns and Practices
Dependency injection
Patterns For Building Composite Applications With WPF
Tame Your Software Dependencies for More Flexible Apps
CAG for WPF and it's components:
Stock trader UI composition:
Порядок иницициализации WPF приложения с контейнером и Prism (componentWPF)

Serive locator и Dependency injection, входящие в состав Unity:

Monday, November 2, 2009
Unity Application Block





