zhaw-dnet2/Tasks/Lab7/RankingServer/RankingService.cs

48 lines
1.3 KiB
C#

namespace RankingServer
{
public class RankingService : IRankingService
{
private string[] ranks = {
"Mueller Stefan,02:31:14",
"Marti Adrian,2:30:09",
"Kiptum Daniel,2:11:31",
"Ancay Tarcis,2:20:02",
"Kreibuhl Christian,2:21:47",
"Ott Michael,2:33:48",
"Menzi Christoph,2:27:26",
"Oliver Ruben,2:32:12",
"Elmer Beat,2:33:53",
"Kuehni Martin,2:33:36"
};
private Lazy<List<Competitor>> competitors;
public RankingService()
{
competitors = new Lazy<List<Competitor>>(
() =>
{
List<Competitor> ranklingList = new List<Competitor>();
foreach (string rank in ranks)
{
string[] fields = rank.Split(',');
Competitor competitor = new()
{
Name = fields[0],
Time = fields[1]
};
ranklingList.Add(competitor);
};
return ranklingList;
});
}
public List<Competitor> RankingList()
{
return competitors.Value;
}
}
}