public Exchange(Guid playerOutId, Guid playerInId, MatchMinute timeOfExchange) { if (IsValidInparameters(playerOutId, playerInId, timeOfExchange)) { PlayerOutId = playerOutId; PlayerInId = playerInId; TimeOfExchange = timeOfExchange; } }
public Event(Guid playerId, MatchMinute timeOfEvent) { if (playerId == Guid.Empty) { throw new ArgumentException($"{nameof(playerId)} cannot be an empty Guid."); } PlayerId = playerId; TimeOfEvent = timeOfEvent; }
public static bool TryParse(int minute, out MatchMinute result) { try { result = new MatchMinute(minute); return(true); } catch (ArgumentException) { result = null; return(false); } }
private bool IsValidInparameters(Guid playerOutId, Guid playerInId, MatchMinute timeOfExchange) { if (playerOutId == Guid.Empty) { throw new ArgumentException($"{nameof(playerOutId)} cannot be an empty Guid."); } if (playerInId == Guid.Empty) { throw new ArgumentException($"{nameof(playerInId)} cannot be an empty Guid."); } if (0 > timeOfExchange.Value || timeOfExchange.Value > MatchMinute.MaxValue) { throw new ArgumentOutOfRangeException($"{nameof(timeOfExchange)} must be between 0 and {MatchMinute.MaxValue}"); } return(true); }