MVP를 이해하려면 귀하의 도움이 필요합니다. 인터페이스 (IProductEditorView
)를 사용했습니다. 아래를 보면 프리젠 테이션 레이어를 볼 수 있습니다 :모델 발표자 인터페이스 질문보기?
using System;
using System.Collections.Generic;
using System.Text;
using MVPProject.BusinessLayer;
namespace MVPProject.PresentationLayer
{
public interface IProductEditorView
{
int ProductID { get;}
string ProductDescription { get; }
event EventHandler<EventArgs> Save;
}
public class ProductEditorPresenter
{
private IProductEditorView mView;
public ProductEditorPresenter(IProductEditorView view)
{
this.mView = view;
this.Initialize();
}
private void Initialize()
{
this.mView.Save += new EventHandler<EventArgs>(mView_Save);
}
private void mView_Save(object sender, EventArgs e)
{
Product product;
try
{
product = new Product();
product.Description = mView.ProductDescription;
product.ID = mView.ProductID;
product.Save();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
throw;
}
}
}
}
ProductListPresenter(IProductEditorView view)
하지만 그들은 내게 (this)
을 추가하기 때문에 내 머리가 섞여있다. 이유를 모르겠다 "this.mPresenter = new ProductListPresenter(this);
"?
private ProductListPresenter mPresenter;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.mPresenter = new ProductListPresenter(this);
}
아마 asp.net-mvc 태그를 제거해야합니다. – DSO