I am trying to work out how to auto register implementations of an generic abstract class or interface. Here are my classes:
public abstract class AbstractValidator<T> : IValidator<T>
{
public void Validate(T)
{
...
}
}
public class CustomerValidator:AbstractValidator<Customer>
{
...
}
I am trying the following:
_container = new WindsorContainer();
_container.Register(
AllTypes.FromAssemblyContaining<ValidationPatterns>()
.BasedOn<IValidator>()
.WithService.Base()
}));
IValidator<Customer> val = _container.Resolve<IValidator<Customer>>();
Any tips greatly appreciated.
Cheers
You're close.
Should be BasedOn(typeof(IValidator<>))
that is the generic open type.
Cheers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With