Unity auto-factory with params

前端 未结 4 1115
感情败类
感情败类 2020-12-08 22:02

I\'m trying to figure out the correct way to inject an auto-factory which takes params, or even if this is possible with Unity.

For example I know I can do this:

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 22:48

    In case you're looking for a fully typed factory interface (allowing for XML documentation and parameter names, for instance), you could use a NuGet package I created, which you can leverage simply by defining an interface for the factory, and then associating it with the concrete type you want to instantiate.

    Code lives in GitHub: https://github.com/PombeirP/FactoryGenerator

提交回复
热议问题