コード例 #1
0
 private void ThrowIfCanNotAddShips(GameDomainModel game, IEnumerable <ShipDomainModel> ships)
 {
     if (game.Init)
     {
         throw new DataValidationException("Sheeps was already added.");
     }
     if (game.Ended)
     {
         throw new DataValidationException("The game is over.");
     }
     if (!game.CanAddShips(ships))
     {
         // TODO if needs to get specific errors, then you need to add a service to the domain
         //      that will calculate the result of adding ships
         throw new DataValidationException("The specified ships cannot be added to the game.");
     }
 }