도메인 객체가 TrainingPlan
인 경우를 가정 해 봅시다. TrainingPlan
오브젝트과 같이, 다른 도메인의 오브젝트들로 구성되어webforms 및 .ascx 컨트롤이있는 MVP 패턴
DelegateInfo.ascx
Test.ascx
(단일 테스트 도메인 오브젝트의 정보를 표시)
.ascx
제어 작성한
public class TrainingPlan
{
public DelegateInfo DelegateInfo { get; set; } // name, assessor, course name
public IEnumerable<Test> Tests { get; set; } // tests delegate undertook
public IEnumerable<Comment> Comments { get; set; } // comments by assessor
}
Comment.ascx
(단일 설명 도메인 개체에 대한 정보 표시)
각 ascx
컨트롤은 전망 선언 :
public class TestPresenter: ITestPresenter
{
ITestView _view;
ITest _domainObj;
// Test object in domain implements ITest
public TestPresenter(ITestView view, ITest domainObj)
{
// removed: checks for null etc
_view = view;
_domainObj = domainObj;
}
// etc etc
}
도메인 객체에 데이터를 제공 할 것입니다 개체입니다 :
public partial class TestControl : System.Web.UI.UserControl, ITestView
{
// ... implementation of view interface here. Simple properties
}
내 발표자보기 및 도메인 객체 사이의 중간 사람입니다 발표자를 통해보기에서 업데이트 된 입력을받습니다. 그것은 (따라서 이유는이 도메인 층 인치) 데이터의 유효성을 검사
질문 :
MVP에 올바른 도메인 오브젝트에 직접 말하기 발표자인가? 내가 봤 거든 샘플 발표자에서 모델에 직접 액세스하지만 inbuilt 비즈니스 로직과 도메인 개체는 어떨까요?
아래의 논리는 MVP 패턴과 일치합니까?
// Page_Load of PageThatDisplaysTrainingPlan.aspx:
// load full trainingPlan object
var trainingPlan = repository.LoadTrainingPlan(idOfPlan);
// populate test controls
foreach(var test in trainingPlan.Tests)
{
// create test.acx control on this line. Code not added as it is unnecessary
var pres = new TestPresenter(controlJustAdded, test);
// ... add pres to some collection somewhere
}
어떤 조언 또는 코드 오신 것을 환영합니다 샘플에 대한 링크.