I Have three generic interfaces
public interface IRepositorioBase<T> where T : class { }
public interface IServiceBase<T> where T : class {}
public interface IAppBase<T> where T : class {}
for which I have three corresponding concrete generic class implementations
public class RepositorioBase<T> where T : class { }
public class ServiceBase<T> where T : class {}
public class AppBase<T> where T : class {}
and the other class are create using the class generics, example
public class ExpenseCardRepository : RepositoryBase<ExpenseCard>, IExpenseCardRepository{ }
public class ExpenseCardService : ServiceBase<ExpenseCard>, IExpenseCardService
{
private readonly IExpenseCardRepository _repository;
public ExpenseCardService(IExpenseCardRepository repository) : base(repository)
{
_repository = repository;
}
}
public class ExpenseCardApp : AppBase<ExpenseCard>, IExpenseCardApp
{
private readonly IExpenseCardService _service;
public ExpenseCardApp(IExpenseCardService service) : base(service)
{
_service = service;
}
}
I would like a generic code only to bind all types of interfaces depending on the type of class it inherits
These is example Ninject-Generic-Interface but I would like get of subclass.
Configure.Container(x => x.Register(typeof(IRepository<>), typeof(Repository<>));- AlexIExpenseCardApp. - BatteryBackupUnitIExpenseCardRepositoryis a design smell, violates SOLID and leads to maintainability issues. Take a look at this article where this is explained. - Steven