我的 ControllerActionInvoker 可以是单例吗?
ControllerActionInvoker
似乎没有任何需要为每个控制器创建新实例的实现细节。它似乎有两个属性,其中的 setter 从未使用过,而 getter 基本上是对静态成员的惰性引用。
我正在考虑更改 ASP.NET MVC 应用程序中自定义 ControllerActionInvoker 生命周期的范围。我有充分的理由不应该这样做吗?这门课我有什么遗漏的吗?
It doesn't seem like ControllerActionInvoker
has any implementation details that require a new instance to be created for each Controller. It seems to have two properties with setters that are never used, and getters that are basically lazy references to static members.
I am considering changing the scope of my custom ControllerActionInvoker's life cycle in my ASP.NET MVC application. Is there a good reason I shouldn't do this? Is there something I'm missing about this class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以这种方式实现
IActionInvoker
并没有任何隐含的错误。然而,也没有隐性的好处。这取决于您希望如何确定 MVC 生命周期特定组件的范围。
There isn't anything implicitly wrong with implementing the
IActionInvoker
this way.However, there is also no implicit benefit. It depends on how you want to scope that particular component of the MVC lifecycle.