I've been struggling getting DecorateAllWith working on generic interfaces. I've read some posts here where they solved it using interceptors but they seem to be using an older structure map version and it doesn't seem like a "clean" solution.
I would really need some help to get it working with structure map 3
I have a generic repository which i would like to decorate with both logging and caching
public interface IEntityRepository<T> where T : Entities.IEntity
{
}
I have about 20 interfaces that inherit IEntityRepository. Example mu UserRepository
public interface IUserEntityRepository : IEntityRepository<User>
{
}
And then I have the logging decorator concrete type which I would like all instances of IEntityRepository to be decorated with
public class LoggingEntityRepository<T> : IEntityRepository<T> where T : Entities.IEntity
{
private readonly IEntityRepository<T> _repositoryDecorated;
public LoggingEntityRepository(IEntityRepository<T> repositoryDecorated)
{
_repositoryDecorated = repositoryDecorated;
}
}
Or are there other IoC containers better suited for what I am trying to accomplish?
Edit: Is there a way to decorate all interfaces that inherit from IEntityRepository