Please note: I am writing this question.
I have these interfaces in a library/framework I am working on:
interface IRepository<TKey,TModel> where TModel: IModel<TKey>{
void Remove(TModel entity);
}
interface IRepository<T> : IRepository<int, T> where T: IModel { }
interface ISoftDeleteRepository<TKey,TModel> : IRepository<TKey, TModel>
where TModel: IModel<TKey>
{ }
interface ISoftDeleteRepository<TModel>
: ISoftDeleteRepository<int, TModel>, IRepository<TModel> { }
and these implementations
class Repository<TKey,TModel> : IRepository<TKey, TModel>
where TModel: IModel<TKey>
{
void Remove(TModel entity)
{
// actually Delete
}
}
class Repository<T> : Repository<int,T>, IRepository<T>
where T: IModel
{ }
class SoftDeleteRepository<TKey,TModel> : Repository<TKey, TModel> ISoftDeleteRepository<TKey,TModel>
where TModel: ISoftDeleteModel<TKey> {
override void Remove(TModel entity)
{
// actually do an update instead
}
}
class SoftDeleteRepository<TModel>
: SoftDeleteRepository<int, TModel>, ISoftDeleteRepository<TModel>
where TModel: ISoftDeleteModel { }
I inherit and implement my own ISoftDeleteRespository
interface IEventRepository : ISoftDeleteRepository<Event> { }
class EventRepository : SoftDeleteRepository<Event>, IEventRepository { }
When I call iEventRepository.Remove(...)
calls the IRepository
's Remove
in Repository
. I don't want that to happen I want to call ISoftDeleteRepository
's Remove
.
Has any one run into anything like this? The real code just compiles just fine, most of this was reconstructed from memory.