Given the interface where FooRequest and FooResponse are abstract:
public interface IFooHandler<TRequest, TResponse> where TRequest : FooRequest where TResponse : FooResponse
{
TResponse CheckFoo(TRequest request);
}
An implementation of:
public class MyFooHandler : IFooHandler<MyFooRequest, MyFooResponse>
{
public MyFooResponse CheckFoo(MyFooRequest request)
{
/* check for foos */
}
}
How would I register this in Castle Windsor so I can resolve it using (where IoCContainer is a WindsorContainer:
Global.IoCContainer.Resolve<IFooHandler<FooRequest, FooResponse>>();
to resolve an instance of MyFooHandler?
In Castle Windsor you can use such code :
Therefore I find registering and resolving generics pretty simple for registering and resolving generics with interfaces. There a lots of questions on castle and generics around.