Does unity just make clasess with out needing anything registered?

前端 未结 2 1145
逝去的感伤
逝去的感伤 2021-01-24 09:34

I am watching Mike Tautly\'s awesome intro to Prism. It was all making sense, but I got a bit confused in the sixth video.

He has his view class\'s constructor take a p

2条回答
  •  攒了一身酷
    2021-01-24 09:44

    Unity tries to construct the class injecting resolved dependencies in the biggest constructor (with the maximum number of parameter).

    So, if you have such a view model:

    public class ViewModel
    {
        public ViewModel(IMyDependency dependency) { .. }
        ...
    }
    

    you only need to register IMyDependency.

提交回复
热议问题