ASP.NET5.0怎么用ServiceLocator 来自 Microsoft.Practices.ServiceLocation
新创建了ASP.NET5.0的web Application 项目, 基于MVC6,关于依赖注入,之前都是基于servicelocator和structureMap在app开始的加上
ServiceLocator.SetLocatorProvider(() => new StructureMapServiceLocator(初始化的 IContainer));
就可以了,但是在asp.net5.0里的 注册服务如下:
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddEntityFramework()
.AddSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddMvc();
}
问题是我的ServiceLocator怎么跟这里的services联系起来呢?