質問

を介して読んで、eppression のMicrosoft .NETソリューションのアーキテウンドで、プレゼンターとサービス層に関していくつかのものを理解しようとしています。

最初のオフでは、私の発表者は、Initialize()、Save()などのように、サービス層に存在するメソッドを呼び出す必要があります。発表者のクラスレベルにある場合、またはプレゼンターメソッド自体に新しいサービスを定義する必要がありますか?

Second - 本では本書では明らかではありません - プレゼンターからサービス層への処理がどのように機能するのでしょうか。

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);
    }
.

役に立ちましたか?

解決

 IPredictionService predictionService = new PredictionService();
.

これは本当に多くの要因に依存します:

  • プレゼンターのサービスと寿命
  • あなたがDIツールを使用している場合
  • サービスを処分する必要がある場合
  • サービスにアイドルタイムアウトがある場合(たとえば、 WCFプロキシの場合)

    それで本質的には、それは必ずしも建築デザインではありません - それはもっと設計決定です。

    DIツールを使用する場合は、次のいずれかになります。

     IPredictionService predictionService = diContainer.Resolve<IPredictionService>();
    
    .

    またはさらに良い、上記のどれでも、それをプロパティとして宣言し、DIツールはプレゼンターを作成するときにそれを入力することができます。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top