3
을 통해 읽음 기업용 Microsoft .Net 솔루션 설계 및 발표자와 서비스 계층과 관련된 몇 가지 사항을 파악하려고합니다.MVP - 발표자와 서비스 계층 - 서비스 계층 선언 위치
먼저 내 발표자는 initialize(), save() 등의 서비스 레이어에있는 메소드를 호출해야합니다.하지만 서비스 레이어에 대한 참조는 어디에 두어야하나요? Presenter에서 클래스 수준에 있어야합니까? 아니면 발표자 메서드 자체에 새 서비스를 정의해야합니까?
둘째 -이 책에 정말 명확하지 않다 중 - 서비스 계층에 대한 발표자의 처리가 어떻게 작동하는지?
public void ProcessPrediction()
{
//Get the data from the View
string selectedForPolePosition = predictionPageView.DriverPolePosition;
string selectedForSecondPosition = predictionPageView.DriverSecondPosition;
string selectedForThirdPosition = predictionPageView.DriverThirdPosition;
string selectedForFourthPosition = predictionPageView.DriverFourthPosition;
string selectedForFifthPosition = predictionPageView.DriverFifthPosition;
string raceTitle = predictionPageView.RaceTitle;
//Prepare for sending to the Service Layer
PredictionDTO prediction = new PredictionDTO();
prediction.RaceTitle = raceTitle;
//More Filling of the DTO here....
//...
//...
IPredictionService predictionService = new PredictionService();
predictionService.ProcessPrediction(prediction);
}
이
_LifeTime은 발표자의 서비스 수명과 현재까지 한 번에 발표자의 한 가지 방법으로 사용되었습니다. _ DI 도구를 사용하는 경우 _ - 아니요, 사용하고 있지 않습니다. _ 서비스를 폐기해야하는 경우 _ - 사용과 마찬가지로? 아니, 필요한 게 아니야. _ 서비스에 유휴 시간 제한이있는 경우 - 아니요. 마지막 옵션이 좋게 들립니다. 그러나 이것은 DI 도구가 뷰어에서 발표자와 서비스를 인스턴스화하는 데 사용된다는 것을 의미합니다. 맞습니까? –
처분이 필요없고 유휴 시간 제한이 없으면 구성원으로 한 번 선언하고 생성자에서 초기화합니다. 또는 Windsor Castle 또는 Unity와 같은 것을 사용하여 나를 위해 객체 생성을 살펴보십시오. 어쨌든 멤버 변수로 사용하는 것이 더 합리적입니다. – Aliostad