UnityContainer.Resolve or ServiceLocator.GetInstance?

后端 未结 3 1726
北恋
北恋 2021-02-01 23:57

It could seem a stupid question because in my code everything is working, but I\'ve registered a singleton this way with my Unity container _ambientContainer:

3条回答
  •  迷失自我
    2021-02-02 00:24

    I'm assuming that the ServiceLocator type is from the CommonServiceLocator project, and that you're using the Unity adapter, in which case GetInstance invokes container.Resolve, so both lines are equivalent.

    You can view the source here - http://commonservicelocator.codeplex.com/wikipage?title=Unity%20Adapter&referringTitle=Home

提交回复
热议问题