hmm OK - and how ould I do something like that? I assume I have to write my own resolver, which can inject this parameter to my component? If I'm adding such a resolver to my container, I still will have to tell the resolve the actual value to inject.
I didn't mention it, because I don't know if it does matter - this is a web-based app, and the "itemId" depends on the request being served - so the container is most likely only once initialized and then never again :) On 4 Mrz., 23:28, Ayende Rahien <[email protected]> wrote: > if you have just global stuff, you can use a sub resolver to handle that > > On Wed, Mar 4, 2009 at 1:57 PM, Henning <[email protected]>wrote: > > > > > > > Hi, > > > I have an interesting problem. I have a whole bunch of components, > > which are registered in my castle container. I mass-registered them > > either based on a certain naming convention or on a common base- > > interface they implement. This allows me to register all my components > > with just two lines of code (kinda) using the fluent API. > > > So next I build my app using all those nice available components. So > > each components specifies their needs as constructor-parameters. So > > now I'm accessing only a handful of components directly in my app, > > everything else is magically handled by castle. > > > OK, so now comes the catch. I have a component ConfigurationContext, > > which needs an itemId parameter. This needs to be supplied by the app, > > but the component is not resolved by the app, but by the dependencies > > of other components. > > > So I would like to go ahead an tell castle "hey, is anyone needs the > > itemId; it's 42!". > > > I though this must be achievable by using properties. I remembered > > back when working with windsor.config.xml I could pass parameters to a > > component while referencing a property. This was also specified in the > > config-file, but hey, couldn't that be done via code as well? So this > > is the real question: how would I do something like that? So how could > > I tell the castle container that the value of a property called > > "itemId" is 42? > > > And by the way: since I mass-registered all my components I would need > > to adjust the ConfigurationContext component, so that castle know to > > pull the "itemId" property as a paramter for this component. If I > > would register this component individually I would do something like: > > > Container.Register(Component.For<IConfigurationContext> > > ().ImplementedBy<ConfigurationContext>().Parameters(Parameter.ForKey > > ("ItemId").Eq("{itemId}"))); > > > So is there any way to "modify" an existing component-registration?- > > Zitierten Text ausblenden - > > - Zitierten Text anzeigen - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
