Resolve all implementation/services of a type using .Net Core DI [duplicate]

五迷三道 提交于 2020-04-17 19:05:22

问题


I am working on migration from Asp.Net MVC to .Net Core.

In my MVC project we used System.Web.Mvc.DependencyResolver to resolve dependencies which I am trying to replace with .Net Core IServiceProvider

However there is one method provided by IDependencyResolver which I am not sure if has any replacement in .Net Core.

IEnumerable<object> GetServices(Type serviceType);

This is from Sytem.Web.Mvc which I believe gets all the dependencies of any type.

I can't find any such method in IServiceProvider in .Net Core.

Have you come across any such Api?

Thanks for your time.


回答1:


Try resolve IEnumerable of service type.



来源:https://stackoverflow.com/questions/60705421/resolve-all-implementation-services-of-a-type-using-net-core-di

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!