本文整理汇总了C#中Statistics.NewSeasonAverageStatistic方法的典型用法代码示例。如果您正苦于以下问题:C# Statistics.NewSeasonAverageStatistic方法的具体用法?C# Statistics.NewSeasonAverageStatistic怎么用?C# Statistics.NewSeasonAverageStatistic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statistics
的用法示例。
在下文中一共展示了Statistics.NewSeasonAverageStatistic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTeamStatistics
public virtual Statistics GetTeamStatistics(Team team)
{
var stats = new Statistics();
var seasons = _seasonRepository.GetAll();
foreach (var season in seasons)
{
var hasCountedSeason = false;
var average = stats.NewSeasonAverageStatistic(season.Name);
foreach (var race in season.Races)
{
var entries = race.Entries.Where(re => re.Entrant.Team.Id == team.Id);
foreach (var entry in entries)
if (entry != null)
{
stats.Entered += 1;
stats.Poles += entry.QualifyingPosition == 1 ? 1 : 0;
stats.Wins += entry.RacePlace == 1 ? 1 : 0;
stats.Podiums += entry.RacePlace <= 3 ? 1 : 0;
stats.Finished += entry.DidNotFinish ? 0 : 1;
stats.Points += (int) entry.Points;
if (!entry.DidNotQualify)
average.AddQualifyingResult(entry.QualifyingPosition);
if (entry.HasFinished)
average.AddRaceResult(entry.RacePlace);
if (!hasCountedSeason)
{
stats.Seasons += 1;
hasCountedSeason = true;
}
}
var seasonResult = season.GetTeamStandings().SingleOrDefault(e => e.Entrant.Team.Id == team.Id);
if (seasonResult != null)
{
if (seasonResult.Position < stats.BestChampionshipResult)
stats.BestChampionshipResult = seasonResult.Position;
}
}
}
return stats;
}
示例2: GetDriverStatistics
public virtual Statistics GetDriverStatistics(Driver driver)
{
var stats = new Statistics();
var racerRatio = 0.0;
foreach (var season in driver.Contracts.Select(c => c.Season))
{
if (!season.Entrants.Any(x => x.Driver.Id == driver.Id))
continue;
bool hasCountedSeason = false;
var average = stats.NewSeasonAverageStatistic(season.Name);
foreach (var race in season.Races)
{
var entry = race.Entries.FirstOrDefault(re => re.Entrant.Driver.Id == driver.Id);
if (entry != null)
{
if (entry.RacerRatio != null)
racerRatio += entry.RacerRatio.Value;
stats.Entered += 1;
if (season.Year >= 4) stats.FastestLapsEntered += 1;
stats.Poles += entry.QualifyingPosition == 1 ? 1 : 0;
stats.Wins += entry.RacePlace == 1 ? 1 : 0;
stats.Podiums += entry.RacePlace <= 3 ? 1 : 0;
stats.Finished += entry.DidNotFinish ? 0 : 1;
stats.Points += (int) entry.Points;
stats.FastestLaps += race.GotFastestLap(driver) ? 1 : 0;
if (!entry.DidNotQualify)
average.AddQualifyingResult(entry.QualifyingPosition);
if (entry.HasFinished)
average.AddRaceResult(entry.RacePlace);
if (!hasCountedSeason)
{
stats.Seasons += 1;
hasCountedSeason = true;
}
}
var seasonResult =
season.GetDriverStandings().FirstOrDefault(e => e.Entrant.Driver.Id == driver.Id);
if (seasonResult != null)
{
if (seasonResult.Position < stats.BestChampionshipResult)
stats.BestChampionshipResult = seasonResult.Position;
}
}
}
stats.RacerRatio = racerRatio / stats.Entered;
return stats;
}