MVP-主持人应该使用会话吗? [英] MVP - Should the Presenter use Session?

查看:79
本文介绍了MVP-主持人应该使用会话吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Model-View-Presenter模式用于网页.主持人应该了解Session还是应该只有视图知道它?

I am using the Model-View-Presenter pattern for a web page. Should the presenter be aware of Session or should only the view be aware of it?

我想我正在了解的是像Session这样的概念与视图的体系结构非常相关,因此应将其限制为仅由视图使用吗?否则,如果我想在不同体系结构的相似页面上重用演示者,会发生什么事情(或者除非我有计划这样做,否则我不必担心这一点)?

I guess what I am getting at is that concepts like Session are very related to the architecture of the view so should they be limited to use by the view? Otherwise what would happen if I wanted to reuse the presenter on a similar page on a different architecture (or do I not need to worry about that unless I have plans to do so)?

推荐答案

我在MVP实现中正在执行类似的操作,我将ICookieManager,ISessionManager,ICacheManager,IConfigurationManager,IRedirector注入到我的演示者中,这些实现由包装了功能.

I am doing something like this in my MVP Implementation I inject an ICookieManager, ISessionManager, ICacheManager, IConfigurationManager, IRedirector into my presenter which are implemented by classes that wrap the functionality for this.

这使演示者可以在其中注入这些模型的模拟版本,并且您在演示者中没有对asp.net运行时的直接依赖,因此使测试变得更加容易.

This allows for a presenter where you can inject mocked versions of these in and you have no direct dependancies on the asp.net runtime in your presenter so it makes testing easier.

欢呼

这篇关于MVP-主持人应该使用会话吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆