/// <summary> /// Tries to get the current standings for a single team. /// </summary> /// <param name="team">Team to query for in the standings.</param> /// <param name="divisionStandings">The division standings, if any were found. If not, this may be anything, but is most likely null.</param> /// <returns>True if that team was found, false otherwise.</returns> public bool TryGetStandingsForTeam(BaseballTeam team, out BaseballTeamStanding divisionStandings) { divisionStandings = null; Func <BaseballTeamStanding, bool> teamNameCheck = division => division.Team.Key.Equals(team.Key); if (_divisionalStandings.Any(teamNameCheck)) { divisionStandings = _divisionalStandings.Single(teamNameCheck); } return(divisionStandings != null); }
/// <summary> /// Indicates whether the given object is equal or not. /// In this case, this == obj iff the divisions match up and both are BaseballTeams. /// </summary> /// <param name="obj">Other object to check.</param> /// <returns>True if they are considered equal, false otherwise.</returns> public override bool Equals(object obj) { if (!base.Equals(obj)) { return(false); } BaseballTeam other = obj as BaseballTeam; if (other == null) { return(false); } return(other.Division.Equals(Division)); }