How can I use Unity with internal classes?

前端 未结 3 1465
孤城傲影
孤城傲影 2021-01-19 10:06

I have a Web API application and am using Unity for dependency injection. The application uses a library containing an Interface IDoStuff and a class that implements the int

3条回答
  •  [愿得一人]
    2021-01-19 10:38

    I've posted my own answer as I believe it comes closest to answering my original question. It may not be as clean a design choice as Steven's recommendations but love it or hate it, it does allow for the internal classes of a library to be used in conjunction with Unity.

    I needed to make three updates to the classes/interfaces:

    1. Make the interfaces public.
    2. Make the constructors public.
    3. Introduce a static class/method that performs unity registration within the library that is called from the main unity registration logic performed on application start up.

提交回复
热议问题