I am wiring up my first SubSonic 3 application (in an ASP.NET MVC 1.0 front-end) and am looking at Rob's SimpleRepository. I'm using Castle.Windsor as an injection framework.
In my application startup, I configure Castle to bind a SubSonic SimpleRepository to a SubSonic IRepository. Nothing complicated there. However, the SimpleRepository has a ctor overload which takes two values: a connection string name and a set of SimpleRepositoryOptions. Not having dug too deep into Castle in the past, it's not clear if there is a way to specify the ctor arguments via configuration (or some other means).
Right now, I have a custom implementation of the SimpleRepository that explicitly creates a SimpleRepository with those arguments in it's parameterless ctor, but if I want to change these at any point in time, it requires changing the code and recompiling.
Is there a more elegant way to configure Castle to take constructor arguments?
If you're configuring Windsor using an XML file, you define your ctor arguments and their values like this:
<component id="repository" service="IRepository" type="SimpleRepository" ...> <parameters> <connectionString>your connection string</connectionString> ... </parameters> </component>
See the Windsor configuration reference for more info:
http://www.castleproject.org/container/documentation/v1rc3/manual/windsorconfigref.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With