public override Task <MemoryImage> LoadThumbnailImageAsync(HttpClient http, CancellationToken cancellationToken) { return(Task.Run(async() => { var apiConnection = TonTwitterCom.GetApiConnection(); using (var imageStream = await apiConnection.GetStreamAsync(new Uri(this.ThumbnailImageUrl), null) .ConfigureAwait(false)) { cancellationToken.ThrowIfCancellationRequested(); return await MemoryImage.CopyFromStreamAsync(imageStream) .ConfigureAwait(false); } }, cancellationToken)); }
public override Task <MemoryImage> LoadThumbnailImageAsync(HttpClient http, CancellationToken cancellationToken) { // TODO: HttpClient を使用したコードに置き換えたい return(Task.Run(async() => { var oauth = new HttpOAuthApiProxy(); TonTwitterCom.InitializeOAuthToken(oauth); Stream response = null; var statusCode = oauth.GetContent("GET", new Uri(this.ThumbnailUrl), null, ref response, Networking.GetUserAgentString()); using (response) { if (statusCode != HttpStatusCode.OK) { throw new WebException(statusCode.ToString(), WebExceptionStatus.ProtocolError); } return await MemoryImage.CopyFromStreamAsync(response) .ConfigureAwait(false); } }, cancellationToken)); }