I hope the title makes at least some sense.
I have the situation as in the code below. The test passes, but I would like to register
GenericCommandHandler<>
as open generic type as implementation for
IHandler<GenericCommand<>>
I can live with the thing below, because the number of types given to GenericCommandHandler is limited and I can register them all individually, but would like something more "automated".
using Castle.MicroKernel.Registration;
using Castle.Windsor;
using NUnit.Framework;
[TestFixture]
public class Class1
{
[Test]
public void t()
{
using( var container = new WindsorContainer() )
{
// HOW TO REGISTER IT AS OPEN GENERIC TYPE?
container.Register(
Component.For<IHandler<GenericCommand<object>>>()
.ImplementedBy<GenericCommandHandler<object>>() );
var handler = container.Resolve<IHandler<GenericCommand<object>>>( );
}
}
}
public interface IHandler<TCommand>
{
void Handle(TCommand o);
}
public class GenericCommand<T>
{
}
public class GenericCommandHandler<T> : IHandler<GenericCommand<T>>
{
public void Handle( GenericCommand<T> o )
{
}
}