Simple Injector 是否放弃了对 CommonServiceLocator 的支持?
Is Simple Injector dropping support for CommonServiceLocator?
我正在阅读这个 SO 问题:
在里面,我看到了这样一句话:
I fixed this and pushed v2.8.2 of the CommonServiceLocator adapter to
NuGet. But note that we are dropping support for the CSL adapter in v3
of Simple Injector because it leads to bad practice. Don't use it; you
don't need it.
这是什么意思?
这是否意味着此代码将不再有效?
// configuration
var container = new Container();
InitializeContainer(container);
container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
// access
var container = GlobalConfiguration.Configuration.DependencyResolver;
var myObject = container.GetService(typeof(MyObject)) as MyObject;
如果是这样,我可以投票决定删除此访问权限 不 吗?我们不经常使用服务定位器模式,但我们有几个关键的功能位,我们别无选择。如果我们不能使用 DependencyResolver,我们将不得不重新使用静态变量。
Just what does this mean?
表示来自v3 and beyond we will not support a NuGet package for the Common Service Locator项目。而已。而已;仅此而已。
所以这意味着如果您想使用 Common Service Locator 项目,您可以尝试使用 CommonServiceLocator.SimpleInjector NuGet package for v2.x that is not guaranteed to keep working in newer versions of v3 and beyond. So it might be wiser to write your own adapter.
这并不意味着我们放弃对 Web API、MVC 和所有其他使用某种 IDependencyResolver
适配器的框架的支持。有可用的集成包,它们仍然受支持。所以代码示例 here and here 仍然正确,您的代码示例应该可以正常工作。
我正在阅读这个 SO 问题:
在里面,我看到了这样一句话:
I fixed this and pushed v2.8.2 of the CommonServiceLocator adapter to NuGet. But note that we are dropping support for the CSL adapter in v3 of Simple Injector because it leads to bad practice. Don't use it; you don't need it.
这是什么意思?
这是否意味着此代码将不再有效?
// configuration
var container = new Container();
InitializeContainer(container);
container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
// access
var container = GlobalConfiguration.Configuration.DependencyResolver;
var myObject = container.GetService(typeof(MyObject)) as MyObject;
如果是这样,我可以投票决定删除此访问权限 不 吗?我们不经常使用服务定位器模式,但我们有几个关键的功能位,我们别无选择。如果我们不能使用 DependencyResolver,我们将不得不重新使用静态变量。
Just what does this mean?
表示来自v3 and beyond we will not support a NuGet package for the Common Service Locator项目。而已。而已;仅此而已。
所以这意味着如果您想使用 Common Service Locator 项目,您可以尝试使用 CommonServiceLocator.SimpleInjector NuGet package for v2.x that is not guaranteed to keep working in newer versions of v3 and beyond. So it might be wiser to write your own adapter.
这并不意味着我们放弃对 Web API、MVC 和所有其他使用某种 IDependencyResolver
适配器的框架的支持。有可用的集成包,它们仍然受支持。所以代码示例 here and here 仍然正确,您的代码示例应该可以正常工作。