各位大侠请帮忙,MVC/MVP模式接口编译错误,没辙了!
很简单的一个MVP接口实现:
//View接口
namespace WebClient1.Products.Views
{
public interface IProductNewView
{
List<Product> Products { set; }
}
}
//View实现
namespace WebClient1.Products.Views
{
public partial class ProductNew : Microsoft.Practices.CompositeWeb.Web.UI.Page, IProductNewView
{
private ProductNewPresenter _presenter;
private List<Product> _p=null;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
}
this._presenter.OnViewLoaded();
}
[CreateNew]
public ProductNewPresenter Presenter
{
get
{
return this._presenter;
}
set
{
if(value == null)
throw new ArgumentNullException("value");
this._presenter = value;
this._presenter.View = this;
}
}
// TODO: Forward events to the presenter and show state to the user.
// For examples of this, see the View-Presenter (with Application Controller) QuickStart:
public List<Product> Products
{
set
{
_p = value;
}
}
}
}
//Presenter
namespace WebClient1.Products.Views
{
public class ProductNewPresenter : Presenter<IProductNewView>
{
// NOTE: Uncomment the following code if you want ObjectBuilder to inject the module controller
// The code will not work in the Shell module, as a module controller is not created by default
//
private IProductsController _controller;
public ProductNewPresenter([CreateNew] IProductsController controller)
{
_controller = controller;
}
public override void OnViewLoaded()
{
// TODO: Implement code that will be executed every time the view loads
View.Products = _controller.Products;
}
}
}
编译错误:
错误 2 “WebClient1.Products.Views.ProductNew”不实现接口成员“WebClient1.Products.Views.IProductNewView.Products”。“WebClient1.Products.Views.ProductNew.Products”无法实现“WebClient1.Products.Views.IProductNewView.Products”,因为它没有匹配的返回类型“System.Collections.Generic.List<WebClient1.Products.Interface.Product>”。 c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\webclient1\6dba2d22\5c066a95\App_Web_1wkctjkb.2.cs 15
//View接口
namespace WebClient1.Products.Views
{
public interface IProductNewView
{
List<Product> Products { set; }
}
}
//View实现
namespace WebClient1.Products.Views
{
public partial class ProductNew : Microsoft.Practices.CompositeWeb.Web.UI.Page, IProductNewView
{
private ProductNewPresenter _presenter;
private List<Product> _p=null;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this._presenter.OnViewInitialized();
}
this._presenter.OnViewLoaded();
}
[CreateNew]
public ProductNewPresenter Presenter
{
get
{
return this._presenter;
}
set
{
if(value == null)
throw new ArgumentNullException("value");
this._presenter = value;
this._presenter.View = this;
}
}
// TODO: Forward events to the presenter and show state to the user.
// For examples of this, see the View-Presenter (with Application Controller) QuickStart:
public List<Product> Products
{
set
{
_p = value;
}
}
}
}
//Presenter
namespace WebClient1.Products.Views
{
public class ProductNewPresenter : Presenter<IProductNewView>
{
// NOTE: Uncomment the following code if you want ObjectBuilder to inject the module controller
// The code will not work in the Shell module, as a module controller is not created by default
//
private IProductsController _controller;
public ProductNewPresenter([CreateNew] IProductsController controller)
{
_controller = controller;
}
public override void OnViewLoaded()
{
// TODO: Implement code that will be executed every time the view loads
View.Products = _controller.Products;
}
}
}
编译错误:
错误 2 “WebClient1.Products.Views.ProductNew”不实现接口成员“WebClient1.Products.Views.IProductNewView.Products”。“WebClient1.Products.Views.ProductNew.Products”无法实现“WebClient1.Products.Views.IProductNewView.Products”,因为它没有匹配的返回类型“System.Collections.Generic.List<WebClient1.Products.Interface.Product>”。 c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\webclient1\6dba2d22\5c066a95\App_Web_1wkctjkb.2.cs 15
...全文
相关推荐
android中的mvc与mvp模式的小demo
如果验证成功,更新视图(显示成功信息),否则提示错误信息。通过这个例子,我们可以看到MVC和MVP如何帮助组织代码,使职责更清晰,更容易理解和维护。
MVC MVP MVVM面试题
MVC、MVP、MVVM面试题MVC模型-view-controller(控制器)是一种软件架构模式,主要用于将应用程序分为三部分:模型、视图和控制器。
Android MVP模式
- 如果失败,则通知View显示错误的消息。#### 六、MVP模式的局限性尽管MVP模式带来了诸多好处,但它也有一些局限性:1.
从三层架构到MVC-MVP
"本文讨论了从传统的三层架构到MVC(模型-视图-控制器)和MVP(模型-视图- presenter)架构的转变,分析了MVC模式的起源、适用场景及其优缺点,同时也提及了在大型项目中如何有效地运用M
详解Android MVP开发模式
**MVP与MVC的区别**在MVC模式中,Controller负责协调View和Model。



