About q3: But if a service needs a reference to another service is this the correct way of doing it? I mean I have never used a DI framework before so I dont know how architecture decisions change. So normally I would have a singleton service class DateService and do DateService.Instance.DoSomething() from a timeservice class method. How does this change when using castle?
On Apr 26, 12:56 pm, "Henrik Feldt" <[email protected]> wrote: > 1. You can define a facility and group the services in the Init in that and > use <facility ... > in your config. > > What do you mean by "mixed up in the components element"? > > 2. Probably an overload for Resolve, since it returns T or object. > > 3: > > class SomeTimeService { public SomeTimeService(IDateService ds) { _Ds = ds; > > } IDateService _Ds; } > > and > > Kernel.Register(Component.For<ITimeService>().ImplementedBy<SomeTimeService> > (), > Component.For<IDateService>.ImplementedBy< AnotherTimeService >()); > > And then > > Kernel.Resolve<ITimeService>(); // will inject IDateService in c'tor > > Is this what you're asking for? You can specify the parameter ids in both > xml: > <component ...> > <parameters> > <ds>#{another.time.service}</ds> > </parameters> > </component> > > And fluent cfg. More on castle's web site. > > -----Original Message----- > From: [email protected] > > [mailto:[email protected]] On Behalf Of Yannis > Sent: den 25 april 2009 12:29 > To: Castle Project Users > Subject: Question about injecting a dictionary collection > > Hi all, > > I am new to castle so I have a few questions: > > 1) In my config file can I somehow group the service implementations for > each service? > > e.g. > <component > id="timeService_1" service="SomeService.ITimeService, > SomeService" > type="SomeService.SomeTimeService, SomeService" /> <component > id="timeService_2" service="SomeService.ITimeService, > SomeService" > type="SomeService.AnotherTimeService, SomeService" /> <component > id="dateService_1" service="SomeService.IDateService, > SomeService" > type="SomeService.DateService, SomeService" /> > > Is there any way to define the time services in one place and the date > services in another (so not all mixed up in the components element > > 2) What does the method GetService do on the IWindsorContainer? > > 3) in the example above, Is there any way to get the date service to somehow > get a reference to the time services? I would like to have access to all of > them and access them through their id. Something like > someCollection["timeService_1"] to get the time service object. > However, I dont want to restrict the service to be using the castle > container. > > Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
