私は、汎用インターフェイスで DecorateAllWith を動作させるのに苦労しています。ここで、インターセプターを使用して解決したいくつかの投稿を読みましたが、古い構造マップ バージョンを使用しているようで、「クリーンな」ソリューションのようには見えません。
構造マップ3で動作させるには、本当に助けが必要です
ロギングとキャッシングの両方で装飾したい汎用リポジトリがあります
public interface IEntityRepository<T> where T : Entities.IEntity
{
}
IEntityRepository を継承する約 20 のインターフェイスがあります。例 mu UserRepository
public interface IUserEntityRepository : IEntityRepository<User>
{
}
そして、IEntityRepository のすべてのインスタンスを装飾したいロギング デコレータの具象型があります。
public class LoggingEntityRepository<T> : IEntityRepository<T> where T : Entities.IEntity
{
private readonly IEntityRepository<T> _repositoryDecorated;
public LoggingEntityRepository(IEntityRepository<T> repositoryDecorated)
{
_repositoryDecorated = repositoryDecorated;
}
}
または、私が達成しようとしていることに適した他の IC コンテナーはありますか?
編集: IEntityRepository から継承するすべてのインターフェイスを装飾する方法はありますか