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]<javascript:>
> > 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
>> [email protected]<javascript:>
>> .
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>.
>> 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 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.