Unity framework DependencyAttribute only works for public properties?

前端 未结 8 1204
小鲜肉
小鲜肉 2021-02-14 17:31

I was trying to clean up some accessability stuff in my code, and inadvertently broke Unity dependency injection. After a while I realized that I marked some public properties t

8条回答
  •  我在风中等你
    2021-02-14 18:01

    If the property is get-only, it makes more sense to use contructor injection rather than property injection.

    If Unity did use reflection to set private or internal members, it would be subjected to code access security constraints. Specifically, it wouldn't work in a low-trust environment.

提交回复
热议问题