Custom object factory extension for Unity

后端 未结 4 1259
你的背包
你的背包 2021-01-02 06:05

I am using the Unity IoC container, and I need to intercept any calls to Resolve for a certain base interface, and run my own custom code to construct those types.

4条回答
  •  走了就别回头了
    2021-01-02 06:35

    The Unity container already acts as a factory that knows how to construct (and perform dependency injection for) arbitrary types, so your factory that accepts a Type t appears redundant. Can you elaborate more on why this is not possible?

    If this is truly not possible (more likely just too much work), then perhaps you can register your factory with the container instead?

提交回复
热议问题