I want to extract all of my code from the IoC container library that I selected (Unity). To do this, I created the IContainer interface, which provides the functions Register () and Resolve (). I created a class called UnityContainerAdapter that implements IContainer and which wraps a real container. Thus, only the assembly in which the UnityContainerAdapter is defined knows about the Unity library.
I have a leak in my isolation. Unity looks for attributes for type members to know where to inject the dependencies. Most of the IoC libraries I've seen also support this. The problem with me is that I want to use this function, but I do not want my classes to depend on a specific Unity attribute.
Do you have any suggestions to fix this problem?
Ideally, I would create my own [Dependency] attribute and use it in my code. But I would have to tell the real container to search for my attribute instead of its own.
source share