I try to register concrete class that is based on generic class, and this generic class is based on generic interface. The problem is how to do this in Castle Windsor and ASP.NET Boilerplate such that I don't need many code that register it one by one.
public interface IService<T> where T: class ...
public class Service<T, TE, TPrimary> : IService<T> where T: class ...
public class ConcreteService : Service<SomeType, SomeType2, string> ...
public class AnotherConcreteService : Service<AnotherSomeType, AnotherSomeType2, string> ...
With such structure, I would like to register to IService<SomeType> the class ConcreteService, which implements this service. How could I do that with Castle Windsor? Implementation one by one looks like this:
IocManager.IocContainer.Register(Component.For(typeof(IQueryService<SomeType>))
.ImplementedBy(typeof(ConcreteService)).Named("ConcreteTest"));
IocManager.IocContainer.Register(Component.For(typeof(IQueryService<AnotherSomeType>))
.ImplementedBy(typeof(AnotherConcreteService)).Named("AnotherConcreteTest"));
Usage that I would like to have:
var test1 = IocContainer.Resolve<IQueryService<SomeType>(); // Here should be ConcreteService
var test2 = IocContainer.Resolve<IQueryService<AnotherSomeType>(); // Here should be AnotherConcreteService
With line by line approach, it works, but how to register all based on IQueryService<>?