Thanks I have already seen IHandlersSelector. After I have chosen a handler how can I inject the dependencies extracted from the requested component name? I tried to return a fresh instance of IHandler but I had problems with initializing it properly. First I needed IKernelInternal. Having supplied it then it seems that ComponentModel is incomplete and has no constructors. This one I'm not sure how to populate.
I did however managed to implement a IHandlersSelector in a hackish way. When a recognized component key is requested I parse it to extract the dependency values and register a new component with IKernel. The gotcha is that a check must be made to ensure that registration hasn't been made already. Otherwise StackOverflowException is thrown. Is this a terrible usage or is that the only way to dynamically register components at resolve-time? Regards, Tom On 2 Sty, 17:18, Patrick Steele <[email protected]> wrote: > I think a Handler Selector would work in this case: > > http://docs.castleproject.org/Windsor.Handler-Selectors.ashx > > --- > Patrick Steelehttp://weblogs.asp.net/psteele > > On Wed, Jan 2, 2013 at 10:43 AM, Tomek Pluskiewicz <[email protected]>wrote: > > > > > > > > > Hi > > > Yes there is only one implementation but it is used as a dependency and > > configured to be resolved by name. The reader is configured in code > > > Component.For<ICsvReader>() > > .ImplementedBy<CommaSeparetedCsvReader>() > > .DependsOn(new { SkipHeader = true, HeaderRowsToSkip = 2 } ) > > .Named("CommaSeparetedCsvReader_Skips2Rows") > > .Lifestyle.Transient > > > Component.For<ICsvReader>() > > .ImplementedBy<CommaSeparetedCsvReader>() > > .DependsOn(new { SkipHeader = true, HeaderRowsToSkip = 1 } ) > > .Named("CommaSeparetedCsvReader_Skips1Row") > > .Lifestyle.Transient > > > Component.For<ICsvReader>() > > .ImplementedBy<CommaSeparetedCsvReader>() > > .Named("CommaSeparetedCsvReader") > > .Lifestyle.Transient > > > These are used as dependency in a processor class. It is configured in > > XML, so that in can be manipulated at runtime > > > <component id="Processor > > type="Processor"> > > <parameters> > > <reader>CommaSeparetedCsvReader_Skips2Rows</reader> > > </parameters> > > </component> > > > Ideally I would like to register only the CommaSeparetedCsvReader > > component but when an attempt is made to resolve > > CommaSeparetedCsvReader_Skips2Rows it should strip the suffix, parse it and > > change the properties accordingly. > > > Is it possible to somehow modify the Resolve() behavior? > > > Thanks > > Tom > > > On Wednesday, January 2, 2013 2:58:49 PM UTC+1, Patrick Steele wrote: > > >> If you only have one implementation of ICsvReader registered then any > >> component that depends on an ICsvReader will get that one component > >> (assuming it's being resolved via Windsor). > > >> I guess I'm confused because you said you have multiple implementations > >> of ICsvReader but you only want to register one of them. Could you give a > >> code example of how you'd like your code to look like in terms of > >> registration and component resolution? > > >> --- > >> Patrick Steele > >>http://weblogs.asp.net/psteele > > >> On Mon, Dec 31, 2012 at 4:13 AM, Tomek Pluskiewicz > >> <[email protected]>wrote: > > >>> Hi > > >>> I have a seemingly simple use case. There is a ICsvReader component. > >>> Let's name it simply Reader here. We load a known set of CSV files and > >>> some of them have headers and some don't. Currently there are multiple > >>> readers: Reader_Skips1Row, Reader_Skips2Rows etc. > > >>> Is there a way to register only one component and have Windsor look at > >>> the component key, strip the "_Skips..." part and resolve the required > >>> component with relevant properties set? > > >>> I have tried subresolver and facility with no luck. > > >>> Thanks, > >>> Tom > > >>> -- > >>> You received this message because you are subscribed to the Google > >>> Groups "Castle Project Users" group. > >>> To post to this group, send email to castle-pro...@**googlegroups.com. > > >>> To unsubscribe from this group, send email to castle-project-users+** > >>> [email protected]. > >>> For more options, visit this group athttp://groups.google.com/** > >>> group/castle-project-users?hl=**en<http://groups.google.com/group/castle-project-users?hl=en> > >>> . > > >> -- > > You received this message because you are subscribed to the Google Groups > > "Castle Project Users" group. > > To view this discussion on the web visit > >https://groups.google.com/d/msg/castle-project-users/-/typu96C1blsJ. > > > 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. -- 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.
