/// <summary> /// Used to compare between CompetitorResults /// </summary> /// <param name="other">The one to compare to</param> /// <returns>Less than zero - This instance is less than obj.</returns> /// <returns>Zero - This instance is equal to obj.</returns> /// <returns>Greater than zero - This instance is greater than obj. </returns> int IComparable <ResultsReturn> .CompareTo(ResultsReturn other) { if (other == null) { return((int)ReturnResult.ThisIsBefore); } switch (CompetitionType) { case Structs.CompetitionTypeEnum.Field: if (!Norwegian) { return((int)IComparableField(other)); } else { return((int)IComparableFieldNorwegian(other)); } case Structs.CompetitionTypeEnum.Precision: return((int)IComparablePrecision(other)); case Structs.CompetitionTypeEnum.MagnumField: return((int)IComparableMagnumField(other)); default: throw new NotSupportedException("CompetitionType " + CompetitionType.ToString() + " is not supported."); } }
private DSResults sortTeams(DSResults results) { string sortExpression = ""; int StationsCount = myInterface.GetStationsCount(); switch (CompetitionType) { case Structs.CompetitionTypeEnum.Field: { if (this.useNorwegianCount) { // Poängfäljtskjutning sortExpression = "NorwPoints desc, Points desc, "; // Add columns for each station for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } } else { // Fältskjutning sortExpression = "Hits desc, FigureHits desc, Points desc, "; for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } } break; } case Structs.CompetitionTypeEnum.MagnumField: { if (this.useNorwegianCount) { // Poängfältskjutning sortExpression = "NorwPoints desc, Points desc, "; // Add columns for each station for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } } else { // Fältskjutning sortExpression = "Hits desc, FigureHits desc, Points desc, "; for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } } break; } case Structs.CompetitionTypeEnum.Precision: { sortExpression = "Hits desc, "; for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { sortExpression += "Station" + stationNr.ToString() + " desc, "; } for (int stationNr = StationsCount; stationNr >= 1; stationNr--) { for (int i = 10; i >= 1; i--) { sortExpression += "Station" + stationNr.ToString() + "-" + i.ToString() + " desc, "; } } break; } default: throw new NotImplementedException(CompetitionType.ToString()); } sortExpression = sortExpression.Trim(); if (sortExpression.Substring(sortExpression.Length - 1, 1) == ",") { sortExpression = sortExpression.Substring(0, sortExpression.Length - 1); } DataRow[] dataRows = results.TeamResults.Select("", sortExpression); DSResults newResults = new DSResults(); foreach (DataRow row in dataRows) { DSResults.TeamResultsRow newRow = newResults.TeamResults.NewTeamResultsRow(); newRow.ClubId = (string)row["ClubId"]; newRow.TeamId = (int)row["TeamId"]; newRow.Hits = (int)row["Hits"]; newRow.FigureHits = (int)row["FigureHits"]; newRow.Points = (int)row["Points"]; newRow.TeamName = (string)row["TeamName"]; newRow.HitsPerStn = (string)row["HitsPerStn"]; newRow.NorwPoints = (int)row["NorwPoints"]; newResults.TeamResults.AddTeamResultsRow(newRow); } return(newResults); }