This question came up on stackoverflow a few days ago: http://stackoverflow.com/questions/3904951/castle-windsor-ioc-passing-constructor-parameters-to-child-components
On Oct 26, 6:34 am, Luis Abreu <[email protected]> wrote: > Hello guys. > > quick question about passing arguments to the resolution process. I've > got this config: > > _container.Register( > Component.For<IFileRetriever>() > .ImplementedBy(typeof(FileRetriever)) > .LifeStyle.Is(_lifeStyle) > ); > > _container.Register( > Component.For<IFileWriter>() > .ImplementedBy(typeof(FileWriter)) > .LifeStyle.Is(_lifeStyle) > ); > > _container.Register( > Component.For<IHexCodeRecoverer>() > .ImplementedBy(typeof(HexCodeRecoverer)) > .LifeStyle.Is(_lifeStyle) > ); > > _container.Register( > Component.For<IDocumentumHexToDataTicketConverter>() > .ImplementedBy(typeof(DocumentumHexToDataTicketConverter)) > .LifeStyle.Is(_lifeStyle) > ); > > _container.Register( > Component.For<FilePathConverter>() > .LifeStyle.Is(_lifeStyle) > ); > > And then, FilePathConverter's constructor looks like this: > > public FilePathConverter( > IFileWriter fileWriter, > IFileRetriever fileRetriever, > IHexCodeRecoverer codeRecoverer, > IDocumentumHexToDataTicketConverter ticketConverter ) { > ... > > Both FileWriter and FileRetriever expect a string that is used > internally: > > public FileWriter( String destinationFolder ) { ... } > > public FileRetriever( String originFolder ) { ... } > > I thought I could get the complete graph by doing something like this: > > var parameters = new Dictionary<String, Object> { > > {"destinationFolder", DestinationFolder}, > > {"originFolder", OriginFolder} > }; > var converter = _container.Resolve<FilePathConverter>( parameters ); > > Unfortunately, it's failing with a missing dependency on FileWriter > (it says it's missing the destinationFolder parameter). > > So, i've noticed that the current context gets pushed into some sort > of stack while trying to resolve the dependencies of a sub-component. > Is this a bug? if not, is there any way to get this working? > > thanks. -- 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.
