我正在阅读《为企业架构Microsoft .Net解决方案》,并尝试理解关于Presenter和Service Layer的几个问题。
首先,我的Presenter需要调用位于Service Layer中的方法,例如initialize()、save()等。但是我应该在哪里放置对Service Layer的引用?它应该在Presenter类级别上,还是应该在Presenter方法本身中定义一个新的service?
其次 - 这在书中并不是很清楚 - Presenter到Service Layer的处理是否是这样工作的?
首先,我的Presenter需要调用位于Service Layer中的方法,例如initialize()、save()等。但是我应该在哪里放置对Service Layer的引用?它应该在Presenter类级别上,还是应该在Presenter方法本身中定义一个新的service?
其次 - 这在书中并不是很清楚 - Presenter到Service Layer的处理是否是这样工作的?
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);
}