I have an ASP.NET MVC app with the following snippet from my Windsor config
(Exhibit B)....

*Notice all three implement the same service interface*...the core question
is which one wins when Resolve<ICatalogService> is called?

Here's what I'm seeing; when calling Resolve<ICatalogService>, the first one
registered wins (*which may not be the algorithm going on under the covers*).
When ICatalogService is a required dependency on another class (Exhibit A) I
am getting a different ICatalogService implementation (in this case the
component with the id "CatalogToControllerService").  The dependency is
resolved in our MVC app using the WindsorControllerFactory provided through
the MvcContrib library.

*Can anyone shed light on why two different services are being returned?*

*Exhibit A:*

public CatalogRequestController(ICatalogService catalogService)

*Exhibit B:*
<component id="CatalogService"
           service="MySuperAwesomeCompany.Services.ICatalogService,
MySuperAwesomeCompany.Services"
           type="MySuperAwesomeCompany.Controller.Services.CatalogService,
MySuperAwesomeCompany.Controller+">
    <parameters>

<catalogServiceFirstTry>${CatalogToControllerService}</catalogServiceFirstTry>

<catalogServiceSecondTry>${CatalogToDBService}</catalogServiceSecondTry>
        <companyNumber>#{Controller.CompanyNumber}</companyNumber>
    </parameters>
</component>

<component id="CatalogToControllerService"
           service="MySuperAwesomeCompany.Services.ICatalogService,
MySuperAwesomeCompany.Services"

type="MySuperAwesomeCompany.Controller.Services.CatalogToControllerService,
MySuperAwesomeCompany.Controller+">
    <parameters>
        <companyNumber>#{Controller.CompanyNumber}</companyNumber>
    </parameters>
</component>

<component id="CatalogToDBService"
           service="MySuperAwesomeCompany.Services.ICatalogService,
MySuperAwesomeCompany.Services"
           type="MySuperAwesomeCompany.Services.CatalogToDBService,
MySuperAwesomeCompany.Services">
    <parameters>
        <companyNumber>#{Controller.CompanyNumber}</companyNumber>
    </parameters>
</component>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" 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-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to