Instead of relying on attributes in the right places, I usually create several types that are actually just aliases. This is useful because with Ninject (and presumably other IoC containers) we query dependencies by type.
So, if you need to βrequestβ a user repository compared to the central one, I would create types that look like this:
interface IRepository { } interface IUserRepository : IRepository {} interface ICentralRepository : IRepository {} class Foo { public Foo(IUserRepository userRepo, ICentralRepository centralRepo) {
I prefer this because then Ninject does not expire at all in my application, it is more declarative, and I think it is easier to remember than any agreement based approach, like the one you are trying.
source share