Unity Auto Injection

I have already done the following:

  • Register an instance of my registrar in unity through the ILogger interface.
  • Created an interface, ILoggableObject, which has a method, Hook (ILogger logger), to enter my logger.

I would like to do this:

Each time I request any permission from one, if this object implements ILoggableObject, it automatically enters the ILogger interface using the Hook method.

I think this is possible through interception or politics?

Any help would be awesome.

+3
source share
3 answers

() . ( ) ILogger , Hook.

+1

Unity IoC/DI, , , .

You can consider aspect-oriented programming using PostSharp or a similar tool. This will allow you to add logging or other cross-cutting issues without changing the classes that the tools overlap.

0
source

Source: https://habr.com/ru/post/1778780/


All Articles