REQUEST A DEMO

Tag: windsor

Windsor Container Property Setter Injection

April 30, 2007     Hammet pointed out in the comments for Creating a simple Windsor facility that the whole premise of my TimeServiceFacility is silly.   Sorry, but I still don't get it why you used a facility to do that. You could get the same behavior by   - registering the timeservice as, well, a service - having writable properties on components, like you do on HasTimeServiceProperty class.   it will be "injected" in the same way.   Interesting exercise, though.   This post is an attempt to correct a wrong. Windsor will do Property setter injection out of the box. Just follow what Hammet said to do a viola you get the same thing.   Add the TimeService as service component to the container:   Container.Current.AddComponent('timeservice', typeof(ITimeService), typeof(TimeService)); Here is a test that proves setter injection is working for components resolved from the container…

Creating a simple Windsor facility

April 11, 2007 Update: What this facility accomplishes is easily done using property setter injection in Windsor. Please use this post only as an example for creating a basic, yet misguided, facility. Windsor is an excellent inversion of control (IoC) container. Besides putting components into the container for use with dependency injection you can extend, customize, tweak, spindle, the behaviors of the container by adding facilities. Facilities expose events and information about what is going on with the container such as what is being added to it and what objects are being created by it. This viewport into the container lets you inject behavior into the lifecycle of objects springing forth from the container. All of this at first is very confusing but lends itself to powerful capabilities. The exercise I went through was to provide a TimeService as an aspect of our application. Normally developers use DateTime.Now…