if you want to resolve a specific implementation based on contextual parameters you will need to build either a sub dependency resolver or service handler selector. a sub dependency resolver is used to resolve a dependency of the primary component. For example foo depends on bar. bar has multiple implementations registered. when you resolve foo a sub dependency resolver will resolve the correct implementation of bar. if you were resolve bar directly you would require a service handler selector.
On Jun 1, 10:16 am, Patrick Steele <[email protected]> wrote: > I think there's a way to do what I want, but I can't quite get the > configuration down. > > We've got an ASP.NET MVC 1 project that's using Windsor. We have two > web.config file (one for development, one for production). The > correct web.config is used depending on active configuration. All of > our windsor configuration is done in web.config. In this app, we have > an ITwitter interface which is used for loading recent tweets. We > have two implementations of ITweet: one is a debug one used during > development (doesn't actually hit the twitter URL so we don't use up > our hourly quota) and the other is used during production (this one > actually hits the twitter URL and returns tweets). > > Most of the pages using ITwitter had output caching enabled. This > further reduced the amount of times the twitter URL was hit. However, > due to some changes, we need to turn off caching in ASP.NET. What I > want to do is create an ITwitter implementation that does the caching > for me. I would like this cached implementation to be able to cache > any ITwitter implementation. Something like this: > > public class CachedTwitter : ITwitter > { > private readonly ITwitter twitter; > > public CachedTwitter(ITwitter twitter) > { > this.twitter = twitter; > } > > // rest of ITwitter implementation which > // delegates calls to this.twitter > > } > > My problem is I'll have two ITwitter components in my web.config -- > one that does the actual work and one that does the caching. I know I > can use the ${component.id} syntax to get the CachedTwitter one to use > another ITwitter implementation as the constructor arg, but how can I > control (or can I control?) which ITwitter is used by the web app? I > obviously want it to use the cached implementation, but with two > ITwitter implementations, how will windsor know which to use -- and > can I give it any "hints" to help it out? > > Thanks. > > --- > Patrick Steelehttp://weblogs.asp.net/psteele -- 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.
