public async Task <AkinatorGuess[]> GetGuess(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); var url = AkiUrlBuilder.GetGuessUrl(BuildGuessRequest(), m_server); var response = await m_webClient.GetAsync(url, cancellationToken).ConfigureAwait(false); var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var result = JsonConvert.DeserializeObject <BaseResponse <Guess> >(content, new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Ignore }); m_lastGuessStep = m_step; return(result.Parameters.Characters.Select(p => new AkinatorGuess(p.Name, p.Description) { ID = p.Id, PhotoPath = p.PhotoPath, Probabilty = p.Probabilty }).ToArray()); }
public async Task <AkinatorGuess[]> GetGuess(CancellationToken cancellationToken = default) { cancellationToken.ThrowIfCancellationRequested(); var url = AkiUrlBuilder.GetGuessUrl(BuildGuessRequest(), _mServer); var response = await _mWebClient.GetAsync(url, cancellationToken).ConfigureAwait(false); var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); var result = EnsureNoError <Guess>(url, content); _mLastGuessStep = _mStep; return(result.Characters.Select(p => new AkinatorGuess(p.Name, p.Description) { ID = p.Id, PhotoPath = p.PhotoPath, Probabilty = p.Probabilty }).ToArray()); }