private async IAsyncEnumerable <Mapler> GetMaplersEnumerableFromUrlAsync(string url) { string page = await _scraper.DownloadPageAsync(url).ConfigureAwait(false); await foreach (Match match in _scraper.GetMatchesInPageAsync(_maplerRegex, page)) { var mapler = new Mapler() { Name = match.Groups["name"].Value, Job = match.Groups["job"].Value, Level = int.Parse(match.Groups["level"].Value), }; if (mapler.Job == "Beginner") { mapler.Job = mapler.Level switch { var x when x < 30 => "Beginner", var x when x >= 30 && x < 70 => "Beginner (30+)", var x when x >= 70 && x < 120 => "Beginner (70+)", _ => "Beginner (120+)", }; } else if (mapler.Job == "Islander") { mapler.Job = mapler.Level switch { var x when x < 30 => "Islander", var x when x >= 30 && x < 70 => "Islander (30+)", var x when x >= 70 && x < 120 => "Islander (70+)", _ => "Islander (120+)", }; } else if (mapler.Job == "Camper") { mapler.Job = mapler.Level switch { var x when x < 30 => "Camper", var x when x >= 30 && x < 70 => "Camper (30+)", var x when x >= 70 && x < 120 => "Camper (70+)", _ => "Camper (120+)", }; } yield return(mapler); } }
private async Task <List <Mapler> > GetMaplersFromUrlAsync(string url) { string page = await _scraper.DownloadPageAsync(url).ConfigureAwait(false); var maplersList = new List <Mapler>(); await foreach (Match match in _scraper.GetMatchesInPageAsync(_maplerRegex, page)) { var mapler = new Mapler() { Name = match.Groups["name"].Value, Job = match.Groups["job"].Value, Level = int.Parse(match.Groups["level"].Value), }; maplersList.Add(mapler); } return(maplersList); }
public int CompareTo(object obj) { Mapler other = (Mapler)obj; if (this.Job.CompareTo(other.Job) == 0) { if (this.Level == other.Level) { return(this.Name.CompareTo(other.Name)); } if (this.Level > other.Level) { return(1); } return(-1); } return(this.Job.CompareTo(other.Job)); }