I am just getting started with Castle Windsor so please excude me if
this has been covered before. I've tried reading the online
documentation, old forums posts and email list but I haven't found
exactly what I am looking for.

I am trying to hook Castle into a new Asp.net MVC project. Below is an
example of what I have working:

      <component id="ProdsRepository"
                 service="DomainModel.Abstract.IProductsRepository,
DomainModel"
                 type="DomainModel.Concrete.FakeProductsRepository,
DomainModel"
                 lifestyle="PerWebRequest">
        <parameters>
          <sport>hockey</sport>
        </parameters>
      </component>

This resolves fine and the test page loads as expected. But what I
really need to be able to do is to have the Asp.net MVC routing engine
supply the "sport" parameter dynamically based upon the incoming URL
(instead of having the parameter being static and listed in the
web.config).

Now, to generate a parameter from MVC routing engine is simple to do
with the following code:
routes.MapRoute(null, "Products/{sport}",
                          new { controller = "Products", action =
"List"});

But if I change the component in the web.config to have an empty value
(assuming that the incoming parameter would be matched up to the
component parameter), like listed below...
        <parameters>
          <sport></sport>
        </parameters>

the page bombs with the following message:
Could not resolve non-optional dependency for
'ProdsRepository' (DomainModel.Concrete.FakeProductsRepository).
Parameter 'sport' type 'System.String'

So how can I change the sport parameter to be dynamic and supplied by
the MVC routing engine during runtime?

Thanks a ton for everyone's time,
Todd Banister

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to