One possible solution is that you could follow convention that Mark Seeman
gives on SO @
http://stackoverflow.com/questions/9339840/register-component-based-on-parameter-name-on-requestor-in-windsor

*Each consumer of **IDataProcessor will signal the intended role of the
dataProcessor by its name.*

public class DataProcessorConvention : ISubDependencyResolver
{
    private readonly IKernel kernel;

    public DataProcessorConvention (IKernel kernel)
    {
        this.kernel = kernel;
    }

    public bool CanResolve(CreationContext context,
        ISubDependencyResolver contextHandlerResolver,
        ComponentModel model,
        DependencyModel dependency)
    {
        return typeof(IDataProcessor).IsAssignableFrom(dependency.TargetType);
    }

    public object Resolve(CreationContext context,
                          ISubDependencyResolver contextHandlerResolver,
                          ComponentModel model,
                          DependencyModel dependency)
    {
        Type representativeSettingsType = typeof (DataProcessorImplementation1);
        Type concreteSettingsType = representativeSettingsType.Assembly
            .GetExportedTypes()
            .Where(t =>
                   t.Name.Equals(dependency.DependencyKey,
                                 StringComparison.OrdinalIgnoreCase))
            .SingleOrDefault();
        return (concreteSettingsType != null
                    ? kernel.Resolve(concreteSettingsType.FullName,
concreteSettingsType)
                    :
kernel.Resolve(representativeSettingsType.FullName,
representativeSettingsType));
    }
}
 public class DataServiceDependsOnImplementation1
{
    private readonly IDataProcessor _dataProcessorImplementation1;

    public DataServiceDependsOnImplementation1(IDataProcessor
dataProcessorImplementation1)
    {
        _dataProcessorImplementation1 = dataProcessorImplementation1;
    }
        ...
}       public class DataServiceDependsOnImplementation2
{
    private readonly IDataProcessor _dataProcessorImplementation2;

    public DataServiceDependsOnImplementation2(IDataProcessor
dataProcessorImplementation2)
    {
        _dataProcessorImplementation2 = dataProcessorImplementation2;
    }
        ...
}       






On Thu, Jan 3, 2013 at 12:53 PM, Sean Farrow
<[email protected]>wrote:

> Hi Fokes:****
>
> I’m new to Winsor and have a quick query:****
>
> I’ve got an interface IDataProcessor. I’ve then got several diferent
> implementations of this interface depending on whee the data is coming
> from.I’ve then got several classes that require tIDataProcessor
> implementations. What I’d like to do is to selectively construct a concrete
> instance depending on the name of the class requesting this.****
>
> I did start looking at IHandlerSelector, but I don’t think this gies me
> the name of the class bein instanciated.****
>
> Can anybody help please?****
>
> Regards****
>
> Sean.****
>
> --
> 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.
>



-- 
Cheers,

Luke Hutton

-- 
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.

Reply via email to