Add decorator or proxy to dependency injection
Microsoft's dependency injection mechanism does not support registering a decorator or a proxy instead of an existing service to the service collection but it still makes it possible to implement an extension method to do it.
Read more