So it appears then that dependency injection cannot be used, other than injecting an IWindsorContainer? Then pulling the named component from the container? I was hoping to implement a solution using multiple ISessionFactory instances as well.
On Mar 25, 5:59 pm, Krzysztof Koźmic <[email protected]> wrote: > via service overrides .DependsOn(Property.ForKey<ISessionFactory>().Is("name > of the component")). > > you only need to do it for where you want to override the default service > that would have been injected, where the default is the first one > registered. So you need the override only where you want to use the 2nd one. > > HTH, > Krzysztof > > On 26 March 2011 08:56, Dave Rathnow <[email protected]> wrote: > > > > > I'm new to Castle and have been trying to convert an application over to > > Castle from Spring.NET/NHibernate using FluentNHibernate. I'm working using > > the sample ToBeSeen project as a reference and have done okay up until I hit > > this problem: > > > My application uses two databases. With Spring.NET/NHibernate I created > > two instances of ISessionFactory and gave them unique names. When injecting > > an ISessionFactory into an object, I specified the name. How do I do this > > with Castle? Assuming I have this: > > > Kernel.Register( > > Component.For<ISessionFactory>() > > .UsingFactoryMethod(config1.BuildSessionFactory) > > .Named("sessionManager1")); > > > Kernel.Register( > > Component.For<ISessionFactory>() > > .UsingFactoryMethod(config2.BuildSessionFactory) > > .Named("sessionManager2")); > > > and a UserRepository mapping: > > > container.Register(Component.For<IUserRepository>() > > .ImplementedBy<UserRepository>() > > .LifeStyle.Transient); > > > container.Register(Component.For<ICompanyRepository>() > > .ImplementedBy<CompanyRepository>() > > .LifeStyle.Transient); > > > How do I inject "sessionManager1" into UserRepository and "sessionManager2" > > into CompanyRepository? > > > Thanks, > > Dave. > > > -- > > 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.- Hide quoted text > >- > > - Show quoted text - -- 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.
