In our projects we’re using Binsor to configure services in our Windsor container. Main reason to do that is Binsor’s extreme expressiveness. It’s much easier to write and maintain next fragment:
import MyApp.Services component IMyService, MyService
compared with standard way of configuring components in Windsor:
<component id="my_service" type="MyApp.Services.IMyService, MyApp" service="MyApp.Services.MyService, MyApp" />
Difference is more evident when you have to maintain files with tens and hundreds of components. Sure, you can use some kind of “autoregistration” for components, this can reduce dramatically size of configuration files.
But, since Binsor is a kind of DSL, is not always evident how to configure complex components that have dependencies and configuration properties to specify. The Binsor’s unit tests are the place where to look for samples, but they don’t cover everything.
Today, I had to configure a NHibernateIntegration facility from Castle with Binsor. After some time I had next solution for configuring two factories:
import Castle.Facilities.NHibernateIntegration import Rhino.Commons import NHibernate.Playground
facility NHibernateFacility:
configuration:
factory:
@id = 'factory_1'
settings(keymap):
dialect = 'NHibernate.Dialect.MsSql2005Dialect'
connection.provider = 'NHibernate.Connection.DriverConnectionProvider'
connection.driver_class = 'NHibernate.Driver.SqlClientDriver'
connection.connection_string = "Server=.\\SQLEXPRESS;initial catalog=test;Integrated Security=SSPI"
assemblies:
assembly = 'NHibernate.Playground'
configuration:
factory:
@id = 'factory_2', alias = 'test2'
settings(keymap):
dialect = 'NHibernate.Dialect.MsSql2005Dialect'
connection.provider = 'NHibernate.Connection.DriverConnectionProvider'
connection.driver_class = 'NHibernate.Driver.SqlClientDriver'
connection.connection_string = "Server=.\\SQLEXPRESS;initial catalog=test2;Integrated Security=SSPI"
assemblies:
assembly = 'NHibernate.Playground'
You can see here the XML way to configure NHibernate facility.
This blog is about things I'm passionated - Software Development, User Experience, gadgets and few other facets of IT that are keeping me busy at work as well as fueling my knowledge and self-improvement demons.